# HG changeset patch # User Laurent Peuch # Date 1575567692 -3600 # Node ID 9b809497978f451c40bc3c78d5660c1367f93d2b # Parent 6cbb1e2a6e49f33451f5b026ee2f7c80d264cb88 [refactoring] blank lines to visually group lines for lisbility diff -r 6cbb1e2a6e49 -r 9b809497978f cubicweb/server/sqlutils.py --- a/cubicweb/server/sqlutils.py Thu Dec 05 18:40:38 2019 +0100 +++ b/cubicweb/server/sqlutils.py Thu Dec 05 18:41:32 2019 +0100 @@ -280,6 +280,7 @@ dbname = source_config['db-name'] except KeyError: raise ConfigurationError('missing some expected entries in sources file') + dbhost = source_config.get('db-host') port = source_config.get('db-port') dbport = port and int(port) or None @@ -288,11 +289,13 @@ dbencoding = source_config.get('db-encoding', 'UTF-8') dbextraargs = source_config.get('db-extra-arguments') dbnamespace = source_config.get('db-namespace') + self.dbhelper = db.get_db_helper(self.dbdriver) self.dbhelper.record_connection_info(dbname, dbhost, dbport, dbuser, dbpassword, dbextraargs, dbencoding, dbnamespace) self.sqlgen = SQLGenerator() + # copy back some commonly accessed attributes dbapi_module = self.dbhelper.dbapi_module self.OperationalError = dbapi_module.OperationalError @@ -310,10 +313,12 @@ if not repairing: statement_timeout = int(source_config.get('db-statement-timeout', 0)) + if statement_timeout > 0: def set_postgres_timeout(cnx): cnx.cursor().execute('SET statement_timeout to %d' % statement_timeout) cnx.commit() + postgres_hooks = SQL_CONNECT_HOOKS['postgres'] postgres_hooks.append(set_postgres_timeout)