|
|
@ -25,13 +25,13 @@ import ast
|
|
|
|
|
|
|
|
|
|
|
|
from sqlalchemy import create_engine
|
|
|
|
from sqlalchemy import create_engine
|
|
|
|
from sqlalchemy import Table, Column, ForeignKey
|
|
|
|
from sqlalchemy import Table, Column, ForeignKey
|
|
|
|
from sqlalchemy import String, Integer, Boolean
|
|
|
|
from sqlalchemy import String, Integer, Boolean, Float
|
|
|
|
from sqlalchemy.orm import relationship, sessionmaker, scoped_session
|
|
|
|
from sqlalchemy.orm import relationship, sessionmaker, scoped_session
|
|
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
session = None
|
|
|
|
session = None
|
|
|
|
cc_exceptions = ['datetime', 'comments', 'float', 'composite', 'series']
|
|
|
|
cc_exceptions = ['datetime', 'comments', 'composite', 'series']
|
|
|
|
cc_classes = {}
|
|
|
|
cc_classes = {}
|
|
|
|
engine = None
|
|
|
|
engine = None
|
|
|
|
|
|
|
|
|
|
|
@ -378,6 +378,11 @@ def setup_db(config):
|
|
|
|
'id': Column(Integer, primary_key=True),
|
|
|
|
'id': Column(Integer, primary_key=True),
|
|
|
|
'book': Column(Integer, ForeignKey('books.id')),
|
|
|
|
'book': Column(Integer, ForeignKey('books.id')),
|
|
|
|
'value': Column(Integer)}
|
|
|
|
'value': Column(Integer)}
|
|
|
|
|
|
|
|
elif row.datatype == 'float':
|
|
|
|
|
|
|
|
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
|
|
|
|
|
|
|
|
'id': Column(Integer, primary_key=True),
|
|
|
|
|
|
|
|
'book': Column(Integer, ForeignKey('books.id')),
|
|
|
|
|
|
|
|
'value': Column(Float)}
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
|
|
|
|
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
|
|
|
|
'id': Column(Integer, primary_key=True),
|
|
|
|
'id': Column(Integer, primary_key=True),
|
|
|
@ -385,7 +390,7 @@ def setup_db(config):
|
|
|
|
cc_classes[row.id] = type(str('Custom_Column_' + str(row.id)), (Base,), ccdict)
|
|
|
|
cc_classes[row.id] = type(str('Custom_Column_' + str(row.id)), (Base,), ccdict)
|
|
|
|
|
|
|
|
|
|
|
|
for cc_id in cc_ids:
|
|
|
|
for cc_id in cc_ids:
|
|
|
|
if (cc_id[1] == 'bool') or (cc_id[1] == 'int'):
|
|
|
|
if (cc_id[1] == 'bool') or (cc_id[1] == 'int') or (cc_id[1] == 'float'):
|
|
|
|
setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]],
|
|
|
|
setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]],
|
|
|
|
primaryjoin=(
|
|
|
|
primaryjoin=(
|
|
|
|
Books.id == cc_classes[cc_id[0]].book),
|
|
|
|
Books.id == cc_classes[cc_id[0]].book),
|
|
|
|