sqlite
SQLite-specific column types.
Blob
Bases: Column[bytes]
Blob column type for storing binary data.
Source code in src/embar/column/sqlite.py
14 15 16 17 18 19 20 | |
Float
Bases: Column[float]
A floating point column type.
Source code in src/embar/column/common.py
159 160 161 162 163 164 165 | |
Integer
Bases: Column[int]
An integer column type.
Source code in src/embar/column/common.py
150 151 152 153 154 155 156 | |
Null
Bases: Column[T | None]
A nullable column type.
Use this as the annotation for columns that can be NULL in the database.
The type parameter T is the underlying Python type (e.g. str, int).
At the class level, Null[str] is a :class:ColumnBase so it works in
order_by, where, Annotated, etc. At the instance level, the
value is typed as T | None.
Convenience aliases are provided: :data:NullText, :data:NullInteger,
:data:NullFloat.
from embar.table import Table
from embar.column.common import Text, NullText, text, integer, NullInteger
class MyTable(Table):
name: Text = text()
email: NullText = text(default=None) # nullable, optional
age: NullInteger = integer(default=None) # nullable, optional
row = MyTable(name="foo")
assert row.email is None
Source code in src/embar/column/common.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
Text
Bases: Column[str]
A text column type.
Source code in src/embar/column/common.py
141 142 143 144 145 146 147 | |
blob(name=None, *, default=NO_DEFAULT, primary=False, not_null=False)
blob(
name: str | None = ...,
*,
primary: bool = ...,
not_null: bool = ...,
) -> Blob
blob(
name: str | None = ...,
*,
default: bytes,
primary: bool = ...,
not_null: bool = ...,
) -> Blob
blob(
name: str | None = ...,
*,
default: None,
primary: bool = ...,
not_null: bool = ...,
) -> NullBlob
Create a :class:Blob column.
Source code in src/embar/column/sqlite.py
52 53 54 55 56 57 58 59 60 61 62 63 64 | |
float_col(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, fk=None, on_delete=None)
float_col(
name: str | None = ...,
*,
primary: bool = ...,
not_null: bool = ...,
fk: Callable[[], Column[float]] | None = ...,
on_delete: OnDelete | None = ...,
) -> Float
float_col(
name: str | None = ...,
*,
default: float,
primary: bool = ...,
not_null: bool = ...,
fk: Callable[[], Column[float]] | None = ...,
on_delete: OnDelete | None = ...,
) -> Float
float_col(
name: str | None = ...,
*,
default: None,
primary: bool = ...,
not_null: bool = ...,
fk: Callable[[], Column[float]] | None = ...,
on_delete: OnDelete | None = ...,
) -> NullFloat
Create a :class:Float column (field specifier for @dataclass_transform).
Source code in src/embar/column/common.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
integer(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, fk=None, on_delete=None)
integer(
name: str | None = ...,
*,
primary: bool = ...,
not_null: bool = ...,
fk: Callable[[], Column[int]] | None = ...,
on_delete: OnDelete | None = ...,
) -> Integer
integer(
name: str | None = ...,
*,
default: int,
primary: bool = ...,
not_null: bool = ...,
fk: Callable[[], Column[int]] | None = ...,
on_delete: OnDelete | None = ...,
) -> Integer
integer(
name: str | None = ...,
*,
default: None,
primary: bool = ...,
not_null: bool = ...,
fk: Callable[[], Column[int]] | None = ...,
on_delete: OnDelete | None = ...,
) -> NullInteger
Create an :class:Integer column (field specifier for @dataclass_transform).
Source code in src/embar/column/common.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
text(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, fk=None, on_delete=None)
text(
name: str | None = ...,
*,
primary: bool = ...,
not_null: bool = ...,
fk: Callable[[], Column[str]] | None = ...,
on_delete: OnDelete | None = ...,
) -> Text
text(
name: str | None = ...,
*,
default: str,
primary: bool = ...,
not_null: bool = ...,
fk: Callable[[], Column[str]] | None = ...,
on_delete: OnDelete | None = ...,
) -> Text
text(
name: str | None = ...,
*,
default: None,
primary: bool = ...,
not_null: bool = ...,
fk: Callable[[], Column[str]] | None = ...,
on_delete: OnDelete | None = ...,
) -> NullText
Create a :class:Text column (field specifier for @dataclass_transform).
Source code in src/embar/column/common.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |