|
|
|
@ -191,6 +191,7 @@ def init_sql(**_args):
|
|
|
|
|
_config = jsonmerge.merge(_config,CUSTOM_CONFIG[TYPE])
|
|
|
|
|
#
|
|
|
|
|
_info = meta(_config)
|
|
|
|
|
|
|
|
|
|
_projectSQLite = [] #-- sqlite projection
|
|
|
|
|
for field_name in _info['main'] :
|
|
|
|
|
_projectSQLite += ["json_extract(data,'$."+field_name+"') "+field_name]
|
|
|
|
@ -211,12 +212,17 @@ def init_sql(**_args):
|
|
|
|
|
SQL = "SELECT DISTINCT :fields FROM "+TABLE_NAME+", json_each(data) x, json_each(x.value) i where x.key = ':table'"
|
|
|
|
|
SQL = SQL.replace(":table",table).replace(":fields",",".join(project))
|
|
|
|
|
r += [{"table":table,"read":{"sql":SQL},"sql":create(table=table,key='claim_id',fields=fields)}]
|
|
|
|
|
|
|
|
|
|
return r
|
|
|
|
|
def init(**_args):
|
|
|
|
|
if 'provider' in CONFIG['store'] and CONFIG['store']['provider'] == 'sqlite' :
|
|
|
|
|
return init_sql(**_args)
|
|
|
|
|
else:
|
|
|
|
|
# if 'provider' in CONFIG['store'] and CONFIG['store']['provider'] == 'sqlite' :
|
|
|
|
|
# return init_sql(**_args)
|
|
|
|
|
# else:
|
|
|
|
|
# return init_mongo(**_args)
|
|
|
|
|
if ('provider' in CONFIG['store'] and CONFIG['store']['provider'] == 'mongo') or ('type' in CONFIG['store'] and 'mongo' in CONFIG['store']['type']):
|
|
|
|
|
return init_mongo(**_args)
|
|
|
|
|
else:
|
|
|
|
|
return init_sql(**_args)
|
|
|
|
|
def init_mongo (**_args) :
|
|
|
|
|
"""
|
|
|
|
|
This function is intended to determine the number of tables to be created, as well as their type.
|
|
|
|
@ -330,6 +336,7 @@ class Factory:
|
|
|
|
|
job_args = init(type=X12_TYPE) #-- getting the queries that will generate the objects we are interested in
|
|
|
|
|
# print (json.dumps(job_args))
|
|
|
|
|
_jobs = []
|
|
|
|
|
|
|
|
|
|
for row in job_args:
|
|
|
|
|
# _store = json.loads(json.dumps(wstore))
|
|
|
|
|
_store = copy.deepcopy(wstore)
|
|
|
|
|