Ejemplo n.º 1
0
def alchemy_url(db_config):
    """Returns a URL representing a database connection."""
    return server.alchemy_url(db_config)
Ejemplo n.º 2
0
from docassemble.base.functions import server
import datetime

custom_db = daconfig.get('variables snapshot db', None)

if custom_db is None:
    from docassemble.webapp.core.models import JsonStorage
    import docassemble.webapp.db_object
    JsonDb = docassemble.webapp.db_object.db.session

    def variables_snapshot_connection():
        return docassemble.webapp.db_object.db.engine.raw_connection()
else:
    Base = declarative_base()

    url = server.alchemy_url('variables snapshot db')

    class JsonStorage(Base):
        __tablename__ = "jsonstorage"
        id = Column(Integer(), primary_key=True)
        filename = Column(String(255), index=True)
        key = Column(String(250), index=True)
        if url.startswith('postgresql'):
            data = Column(JSONB)
        else:
            data = Column(Text())
        tags = Column(Text())
        modtime = Column(DateTime(), server_default=func.now())
        persistent = Column(Boolean(), nullable=False, server_default=false())

    engine = create_engine(url)