import sqlalchemy engine create_engine sqlite dbvivaio echo True metad

 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import sqlalchemy
engine = create_engine('sqlite://dbvivaio', echo=True)
metadata = Metadata()
clients_table = Table('clients', metadata,
Column('id', Integer, primary_key=True),
Column('name', String),
Column('surname', String),
Column('cell', String),
Column('address', String)
)
jobs_table = Table('jobs', metadata,
Column('id',Integer, primary_key=True),
Column('title', String),
Column('cph', Float)
)
workers_table = Table('workers', metadata,
Column('id', Integer, primary_key=True),
Column('name', String),
Column('surname', String),
Column('address', String),
Column('hire_date', Date),
Column('agronomist', Bool),
Column('qualification', Integer, foreign_key('qualification.id')
)
qualification_table = Table('qualification', metadata,
Column('id', Integer, primary_key=True),
Column('descr', String)
)
workers_jobs_table = Table('workerjobs', metadata,
Column('id', Integer, primary_key=True),
Column('workerid', Integer, foreign_key('workers.id')),
Column('jobid', Integer, foreign_key('jobs.id'))
)
jobs_requests_table = Table('jobs_requests', metadata,
Column('id', Integer, primary_key=True),
Column('request_date', Date),
Column('execution_date', Date),
Column('clientid', Integer, foreign_key('clients.id')),
Column('jobid', Integer, foreign_key('jobs.id')),
Column('workerid', Integer, foreign_key('workers.id'))
)
species_table = Table('species', metadata,
Column('id', Integer, primary_key=True),
Column('name', String),
Column('season', String),
Column('cultivation', String),
Column('indoor', Bool),
Column('present', Bool),
Column('agronomistid', Integer, foreign_key('workers.id'))
)
types_table = Table('species_types', metadata,
Column('id', Integer, primary_key=True),
Column('descr', String),
Column('price', Float),
Column('amount', Integer),
Column('specieid', Integer, foreign_key('species.id'))
)
metadata.create_all(engine)