initializedb.py
912 Bytes
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
import os
import sys
import transaction
import subprocess
from sqlalchemy import (
engine_from_config,
select,
)
from sqlalchemy.schema import CreateSchema
from pyramid.paster import (
get_appsettings,
setup_logging,
)
from ..models import (
EisDBSession as ModuleDBSession,
EisBase as ModuleBase,
)
from ..models import *
from . import initial_data
#from .tools import mkdir
from ...scripts.initializedb import create_schema, read_file
from ...tools import get_settings
def main(settings):
'eis'
if 'eis.url' in settings and settings['eis.url']:
engine = engine_from_config(settings, 'eis.')
else:
engine = ModuleDBSession.bind;
create_schema(engine, 'eis')
ModuleBase.metadata.create_all(engine)
ModuleDBSession.configure(bind=engine)
initial_data.insert()
transaction.commit()
print('****EIS CREATED****')