-
Notifications
You must be signed in to change notification settings - Fork 16
/
schema.py
32 lines (27 loc) · 1.14 KB
/
schema.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from sqlalchemy import Column, MetaData, Table
from sqlalchemy.sql.sqltypes import DateTime, Integer, Numeric, Text
meta = MetaData()
schema = [
Table(
"dotace",
meta,
Column("evidencni_cislo_dotace", Text, nullable=True),
Column("identifikator_dotace", Text, nullable=False),
Column("nazev_dotace", Text, nullable=False),
Column("ucastnik", Text, nullable=True),
Column("ic_ucastnika", Integer, nullable=True, index=True),
Column("ucel_dotace", Text, nullable=True),
Column("poskytovatel_dotace", Text, nullable=False),
Column("ic_poskytovatele", Integer, nullable=False, index=True),
Column("castka_pozadovana", Numeric(14, 2), nullable=True),
Column("castka_schvalena", Numeric(14, 2), nullable=True),
Column("datum_poskytnuti", DateTime, nullable=True),
)
]
if __name__ == "__main__":
from sqlalchemy import create_engine
from sqlalchemy.schema import CreateTable
engine = create_engine("sqlite:///:memory:")
for table in schema:
print(f"-- {table.name} as created in SQLite")
print(CreateTable(table).compile(engine))