Typing support for PyDAL
Project description
TypeDAL
Typing support for PyDAL.
This package aims to improve the typing support for PyDAL. By using classes instead of the define_table method,
type hinting the result of queries can improve the experience while developing. In the background, the queries are still
generated and executed by pydal itself, this package only proves some logic to properly pass calls from class methods to
the underlying db.define_table
pydal Tables.
Translations from pydal to typedal
Description | pydal | pydal alternative | typedal | typedal alternative(s) | ... |
Setup |
from pydal import DAL, Field
db = DAL(...)
|
from typedal import TypeDAL, TypedTable, TypedField
from typing import Optional
db = TypeDAL(...)
|
|||
Table Definitions |
db.define_table("table_name",
Field("fieldname", "string", required=True),
Field("otherfield", "float"))
|
@db.define
class TableName(TypedTable):
fieldname: str
otherfield: Optional[float]
|
class TableName(TypedTable):
fieldname: str
otherfield: float | None
db.define(TableName)
|
||
Insert |
db.table_name.insert(fieldname="value")
|
db.table_name.insert(fieldname="value")
|
TableName.insert(fieldname="value")
|
||
(quick) Select |
row = db.table_name(id=1) # -> Any
|
row: TableName = db.table_name(id=1) # -> TableName
|
row = TableName(id=1) # -> TableName
|
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
TypeDal-0.3.0.tar.gz
(4.1 kB
view hashes)