Пример #1
0
 def __init__(self, subdirectory_=None, file_stem=None):
     engine = SqlAlchemyEngine(subdirectory_, file_stem)()
     assert isinstance(engine, sqlalchemy.engine.base.Engine)
     #info (engine.__class__)
     if self._sessionClass is None:
         self._sessionClass = _sessionmaker(bind=engine, autocommit=False)
Пример #2
0
def _getSqliteUrl():
    import os.path
    sqlite_path = os.path.join(getUserDirectory(), "obomb.db")
    info(sqlite_path) 
    sqlite_path_slash = sqlite_path.replace(os.path.sep, '/')
    info(sqlite_path_slash)
    sqlite_url = "sqlite:///" + sqlite_path_slash
    info(sqlite_url)
    return sqlite_url
    
#from logging import debug, info, warn, error, critical, exception
from unittest import TestCase, main
from sqlalchemy import create_engine as _create_engine
engine = _create_engine(_getSqliteUrl(), echo=False)
from sqlalchemy.orm.session import sessionmaker as _sessionmaker
Session = _sessionmaker(bind=engine, autocommit=False)
PersistentSession = _sessionmaker(bind=engine, autocommit=True)
#_metadata = MetaData()
from datetime import datetime as _datetime
from dateutil.tz import tzutc
def utcnow():
    dt = _datetime.utcnow();
    assert isinstance(dt, _datetime)
    assert dt.tzinfo is None
    dt2 = dt.replace(tzinfo=tzutc())
    return dt2

class _TestConfig(TestCase):
    def setUp(self):
        pass