This repository was archived by the owner on Sep 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsamples.py
More file actions
49 lines (38 loc) · 1.22 KB
/
samples.py
File metadata and controls
49 lines (38 loc) · 1.22 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
45
46
47
48
49
from sqlalchemy import (
create_engine, MetaData,
Table, Column,
Integer, String, DateTime, Float
)
from itsjustcode import generateit
def create_db_sample():
db_uri = 'sqlite://'
engine = create_engine(db_uri)
meta = MetaData(engine)
# Register t1, t2 to metadata
t1 = Table('sample_table',
meta,
Column('id', Integer, primary_key=True),
Column('name', String),
Column('cost', Float),
Column('started_at', DateTime))
# Create all tables in meta
meta.create_all()
return engine
if __name__ == '__main__':
engine = create_db_sample()
templates = [
'angularjs/model.ts',
'angularjs/repository.ts',
'angularjs/listcontroller.ts',
'angularjs/list.html',
'angularjs/detailcontroller.ts',
'angularjs/detail.html'
]
bindings = dict(namespace='Just.Code')
for template in templates:
generateit(engine=engine,
table='sample_table',
template_search='samples/templates/',
template_file=template + '.j2',
out_file='samples/output/' + template,
bindings=bindings)