Changeset 8356
- Timestamp:
- 17/06/12 15:01:51 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mauRepo/HPFos/trunk/src/libs/commons_db.py
r8355 r8356 32 32 ''' 33 33 from sqlalchemy import MetaData, create_engine 34 from sqlalchemy.orm import sessionmaker , scoped_session34 from sqlalchemy.orm import sessionmaker 35 35 from sqlalchemy.sql.expression import text 36 36 class DbManagerCollection(object): … … 52 52 Represents a database instance managed by an SQLAlchemy engine. 53 53 """ 54 def __init__(self, connection, script = None, sql_echo=False, session_event_manager = None ):54 def __init__(self, connection, script = None, sql_echo=False, session_event_manager = None, ipool_size = 10): 55 55 """ 56 56 @param connection: the URL used to open a connection to the database … … 58 58 @param sql_echo: sets the SQLalchemy create_engine.echo param. Default is False 59 59 @param session_event_manager: a python method defining session events \ 60 (see http://docs.sqlalchemy.org/en/latest/orm/events.html?highlight=session%20events#sqlalchemy.orm.events.SessionEvents) 60 (see http://docs.sqlalchemy.org/en/latest/orm/events.html?highlight=session%20events#sqlalchemy.orm.events.SessionEvents) 61 @param ipool_size: sets the connections pool size (note that this is the maximum size not the number of the pre-allocated ones) 61 62 """ 62 63 self._connection = connection … … 64 65 self.engine = None 65 66 try: 66 self.engine = create_engine(self._connection, echo=sql_echo)67 self.engine = create_engine(self._connection, pool_size = ipool_size, pool_recycle=3600, echo=sql_echo) 67 68 except Exception as e: 68 69 print e … … 73 74 self._script(self.metadata) 74 75 self.metadata.create_all(bind=self.engine) 75 #self._session = scoped_session(sessionmaker())76 76 if self.engine: 77 77 self.engine.connect()
Note: See TracChangeset
for help on using the changeset viewer.