API Reference¶
The following section outlines the API of postDB.
Model¶
-
class
postDB.Model¶ Base class for all the models.
-
classmethod
all_models() → List[Type[postDB.model.model.Model]]¶ Returns a list of all
Modelsubclasses.
-
async classmethod
create_pool(uri: str, *, min_con: int = 1, max_con: int = 10, timeout: float = 10.0, loop: asyncio.base_events.BaseEventLoop = None, **pool_kwargs) → None¶ Populate the internal pool keyword.
-
async classmethod
create_table(*, verbose: bool = False, exists_ok: bool = True)¶ Create the PostgreSQL Table for this Model.
-
classmethod
create_table_sql(*, exists_ok: bool = True) → str¶ Generates the
CREATE TABLESQL statement.
-
classmethod
Column¶
Column types¶
Base class¶
Types¶
-
class
postDB.types.Array(sql_type: Union[Type[postDB.types.SQLType], postDB.types.SQLType])¶ Type for python
list.{type} ARRAYin PostgreSQL.
-
class
postDB.types.Date¶ Type for python
datetime.date.DATEin PostgreSQL.
-
class
postDB.types.DateTime(*, timezone: bool = False)¶ Type for python
datetime.datetime.TIMESTAMP WITH TIME ZONEorTIMESTAMP WITHOUT TIME ZONEin PostgreSQL.Optional timezone with the
timezoneattribute.
-
class
postDB.types.ForeignKey(model: str, column: str, *, sql_type: Union[Type[postDB.types.SQLType], postDB.types.SQLType, None] = None, on_delete: str = 'CASCADE', on_update: str = 'NO ACTION')¶ Reference to another column in another model.
-
class
postDB.types.Integer(*, big: bool = False, small: bool = False)¶ Type for python
int.INTEGERorBIG INTorSMALL INTin PostgreSQL.Optional big or small integer with
bigandsmall
-
class
postDB.types.Interval(field: str = None)¶ Type for python
datetime.timedelta.INTERVALorINTERVAL {field}in PostgreSQL.Optional field argument for setting the interval type with the
field. field argument needs to be in this list:"YEAR""MONTH""DAY""HOUR""MINUTE""SECOND""YEAR TO MONTH""DAY TO HOUR""DAY TO MINUTE""DAY TO SECOND""HOUR TO MINUTE""HOUR TO SECOND""MINUTE TO SECOND"
-
class
postDB.types.Numeric(*, precision: int = None, scale: int = None)¶ Type for python
decimal.Decimal.NUMERICorNUMERIC({precision}, {scale})in PostgreSQL.Optional precision and scale with
precisionandscale
-
class
postDB.types.Serial(*, big: bool = False, small: bool = False)¶ Type for python
intthat autoincrements.SERIALorBIG SERIALorSMALL SERIALin PostgreSQL.Optional big or small integer with
bigandsmall
-
class
postDB.types.String(*, length: int = None, fixed: bool = False)¶ Type for python
str.TEXTorCHAR({length})orVARCHAR({length})in PostgreSQL.Optional length and fixed with
lengthandfixed
-
class
postDB.types.Time(*, timezone: bool = False)¶ Type for python
datetime.time.TIME WITH TIME ZONEorTIME WITHOUT TIME ZONEin PostgreSQL.Optional timezone with the
timezoneattribute.