コード例 #1
0
ファイル: odm2_measurement_dao.py プロジェクト: emiliom/WOFpy
 def __init__(self, db_connection_string):
     self.engine = create_engine(db_connection_string, convert_unicode=True,
         pool_size=100)
     odm2_models.setSchema(self.engine)
     # Default application pool size is 5. Use 100 to improve performance.
     self.db_session = scoped_session(sessionmaker(
         autocommit=False, autoflush=False, bind=self.engine))
コード例 #2
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()
コード例 #3
0
ファイル: odm2_timeseries_dao.py プロジェクト: emiliom/WOFpy
    def __init__(self, db_connection_string):
        """Initialize Odm2Dao Object."""

        # Default application pool size is 5. Use 100 to improve performance.
        self.engine = create_engine(
            db_connection_string,
            convert_unicode=True,
            # pool_size=100
        )

        odm2_models.setSchema(self.engine)

        Session = scoped_session(
            sessionmaker(
                autocommit=False,
                autoflush=False,
                bind=self.engine
            )
        )

        self.db_session = Session()

        # Read in WaterML -> ODM2 CV Mapping
        with open(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'cvmap_wml_1_1.yml'))) as yml:
            self.yml_dict = yaml.load(yml)
コード例 #4
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()
コード例 #5
0
 def __init__(self, db_connection_string):
     self.engine = create_engine(db_connection_string,
                                 convert_unicode=True,
                                 pool_size=100)
     odm2_models.setSchema(self.engine)
     # Default application pool size is 5. Use 100 to improve performance.
     self.db_session = scoped_session(
         sessionmaker(autocommit=False, autoflush=False, bind=self.engine))
コード例 #6
0
 def testEngine(self, connection_string, echo=False):
     s = SessionFactory(connection_string, echo=echo, version=2.0)
     try:
         setSchema(s.test_engine)
         # s.test_Session().query(Variable2.VariableCode).limit(1).first()
         s.test_Session().execute('Select 1')
     except Exception as e:
         print('Connection was unsuccessful {}'.format(e.message))
         return False
     finally:
         dbconnection.closeConnection(s.test_Session)
     return True
コード例 #7
0
    def __init__(self, connection_string, echo=True, version=2.0):

        if 'sqlite' in connection_string:
            self.engine = create_engine(connection_string,  encoding='utf-8', echo=echo, pool_recycle=100)
            self.test_engine = self.engine
        elif 'mssql' in connection_string:
            self.engine = create_engine(connection_string, encoding='utf-8', echo=echo, pool_recycle=100)
            self.test_engine = create_engine(connection_string, encoding='utf-8',
                                             echo=echo, connect_args={'timeout': 1})
        elif 'postgresql' in connection_string or 'mysql' in connection_string:
            self.engine = create_engine(connection_string, encoding='utf-8', echo=echo, pool_recycle=100)
            self.test_engine = create_engine(connection_string, encoding='utf-8', echo=echo,
                                             max_overflow=0, connect_args={'connect_timeout': 1})

        # Create session maker.
        self.Session = scoped_session(sessionmaker(bind=self.engine, autoflush=True))
        self.test_Session = scoped_session(sessionmaker(bind=self.test_engine))
        setSchema(self.engine)
        self.version = version
コード例 #8
0
    def __init__(self, db_connection_string):
        """Initialize Odm2Dao Object."""

        # Default application pool size is 5. Use 100 to improve performance.
        self.engine = create_engine(
            db_connection_string,
            convert_unicode=True,
            # pool_size=100
        )

        odm2_models.setSchema(self.engine)

        Session = scoped_session(
            sessionmaker(autocommit=False, autoflush=False, bind=self.engine))

        self.db_session = Session()

        # Read in WaterML -> ODM2 CV Mapping
        with open(
                os.path.abspath(
                    os.path.join(os.path.dirname(__file__), '..',
                                 'cvmap_wml_1_1.yml'))) as yml:
            self.yml_dict = yaml.load(yml)