equal
deleted
inserted
replaced
272 |
272 |
273 class SQLAdapterMixIn(object): |
273 class SQLAdapterMixIn(object): |
274 """Mixin for SQL data sources, getting a connection from a configuration |
274 """Mixin for SQL data sources, getting a connection from a configuration |
275 dictionary and handling connection locking |
275 dictionary and handling connection locking |
276 """ |
276 """ |
277 cnx_wrap = ConnectionWrapper |
|
278 |
|
279 def __init__(self, source_config, repairing=False): |
277 def __init__(self, source_config, repairing=False): |
280 try: |
278 try: |
281 self.dbdriver = source_config['db-driver'].lower() |
279 self.dbdriver = source_config['db-driver'].lower() |
282 dbname = source_config['db-name'] |
280 dbname = source_config['db-name'] |
283 except KeyError: |
281 except KeyError: |
301 self.InterfaceError = dbapi_module.InterfaceError |
299 self.InterfaceError = dbapi_module.InterfaceError |
302 self.DbapiError = dbapi_module.Error |
300 self.DbapiError = dbapi_module.Error |
303 self._binary = self.dbhelper.binary_value |
301 self._binary = self.dbhelper.binary_value |
304 self._process_value = dbapi_module.process_value |
302 self._process_value = dbapi_module.process_value |
305 self._dbencoding = dbencoding |
303 self._dbencoding = dbencoding |
|
304 |
306 if self.dbdriver == 'sqlite': |
305 if self.dbdriver == 'sqlite': |
307 self.cnx_wrap = SqliteConnectionWrapper |
306 self.cnx_wrap = SqliteConnectionWrapper |
308 self.dbhelper.dbname = abspath(self.dbhelper.dbname) |
307 self.dbhelper.dbname = abspath(self.dbhelper.dbname) |
|
308 else: |
|
309 self.cnx_wrap = ConnectionWrapper |
|
310 |
309 if not repairing: |
311 if not repairing: |
310 statement_timeout = int(source_config.get('db-statement-timeout', 0)) |
312 statement_timeout = int(source_config.get('db-statement-timeout', 0)) |
311 if statement_timeout > 0: |
313 if statement_timeout > 0: |
312 def set_postgres_timeout(cnx): |
314 def set_postgres_timeout(cnx): |
313 cnx.cursor().execute('SET statement_timeout to %d' % statement_timeout) |
315 cnx.cursor().execute('SET statement_timeout to %d' % statement_timeout) |