Пример #1
0
 def __init__(self, request):
     db = request.param
     print ('dbtype', db[0], db[1])
     session_factory = SessionFactory(db[2])
     setSchema(session_factory.engine)
     assert session_factory is not None, ('failed to create a session for ', db[0], db[1])
     self.session = session_factory.getSession()
Пример #2
0
 def setup(self):
     self.connection_string = "sqlite:///:memory:"
     session_factory = SessionFactory(self.connection_string, echo=False)
     test_util.build_db(session_factory.engine)
     self.session = session_factory.getSession()
     self.series = test_util.add_series(self.session)
     self.data_values = self.series.data_values
Пример #3
0
 def __init__(self, request):
     db = request.param
     print('dbtype', db[0], db[1])
     session_factory = SessionFactory(db[2])
     setSchema(session_factory.engine)
     assert session_factory is not None, ('failed to create a session for ',
                                          db[0], db[1])
     self.session = session_factory.getSession()
    def setup(self):
        self.connection_string = "sqlite:///:memory:"
        self.session_factory = SessionFactory(self.connection_string,
                                              echo=False)
        self.session = self.session_factory.get_session()

        self.series_service = SeriesService(
            connection_string=self.connection_string)
        engine = self.session_factory.engine
        test_util.build_db(engine)
Пример #5
0
    def __init__(self, request):
        #session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')
        db = request.param
        print ("dbtype", db[0], db[1] )
        #session_factory = dbconnection.createConnection(db[0],db[1],db[2],db[3],db[4], echo=True)
        session_factory = SessionFactory(db[2])
        setSchema(session_factory.engine)
        assert session_factory is not None, ("failed to create a session for ", db[0], db[1])
#        assert session_factory.engine is not None, ("failed: session has no engine ", db[0], db[1])
#
 #       insp = reflection.Inspector.from_engine(session_factory.engine)
#        tables = insp.get_table_names()

        self.session = session_factory.getSession()
class TestSessionFactory_1_1:
    def setup(self):
        self.connection_string = "sqlite:///:memory:"
        self.session_factory = SessionFactory(self.connection_string,
                                              echo=True)

    def test_create_session_factory(self):
        assert repr(
            self.session_factory
        ) == "<SessionFactory('Engine(%s)')>" % self.connection_string
        assert self.session_factory.Session != None

    def test_get_session(self):
        session = self.session_factory.get_session()
        assert 'sqlalchemy.orm.session.Session' in repr(session)
class TestPandasMemoryDB_1_1:
    """
    Test to Load up a series from a dataframe and load it into an in memory database
    """
    def setup(self):
        self.connection_string = "sqlite:///:memory:"
        self.session_factory = SessionFactory(self.connection_string,
                                              echo=False)
        self.session = self.session_factory.get_session()

        self.series_service = SeriesService(
            connection_string=self.connection_string)
        engine = self.session_factory.engine
        test_util.build_db(engine)

    def test_build_series(self):
        dvs = 100
        self.series = test_util.add_series_bulk_data(self.session,
                                                     dvs_size=dvs)
        assert self.series
        assert len(self.series.data_values) == dvs
Пример #8
0
def build_session_from_connection_string(connection_string):
    if type(connection_string) != str:
        connection_string = str(connection_string)
    s = SessionFactory(connection_string, echo=False, version=2.0)

    return s
 def setup(self):
     self.connection_string = "sqlite:///:memory:"
     self.session_factory = SessionFactory(self.connection_string,
                                           echo=True)