-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathschema.py
More file actions
44 lines (39 loc) · 1.38 KB
/
Copy pathschema.py
File metadata and controls
44 lines (39 loc) · 1.38 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
from sqlalchemy import Column, MetaData, Table
from sqlalchemy.sql.sqltypes import BigInteger, Integer, Numeric, Text
meta = MetaData()
schema = [
Table(
"zadatele",
meta,
Column(
"id_prijemce",
BigInteger,
nullable=False,
primary_key=True,
autoincrement=False,
),
Column("rok", Integer, nullable=False, primary_key=True, autoincrement=False),
Column("jmeno_nazev", Text, nullable=False),
Column("obec", Text, nullable=True),
Column("okres", Text, nullable=True),
Column("castka_bez_pvp", Numeric(12, 2), nullable=False),
),
Table(
"platby",
meta,
Column("id_prijemce", BigInteger, nullable=False),
Column("rok", Integer, nullable=False),
Column("fond_typ_podpory", Text, nullable=False),
Column("opatreni", Text, nullable=False),
Column("zdroje_cr", Numeric(12, 2), nullable=True),
Column("zdroje_eu", Numeric(12, 2), nullable=True),
Column("celkem_czk", Numeric(12, 2), nullable=False),
),
]
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))