cubicweb/server/sqlutils.py
branch3.24
changeset 11821 7534b32c45e3
parent 11811 f09efeead7f9
child 12047 85416b43310a
equal deleted inserted replaced
11820:ec612abc2e2e 11821:7534b32c45e3
   455 
   455 
   456     # these are overridden by set_log_methods below
   456     # these are overridden by set_log_methods below
   457     # only defining here to prevent pylint from complaining
   457     # only defining here to prevent pylint from complaining
   458     info = warning = error = critical = exception = debug = lambda msg, *a, **kw: None
   458     info = warning = error = critical = exception = debug = lambda msg, *a, **kw: None
   459 
   459 
       
   460 
   460 set_log_methods(SQLAdapterMixIn, getLogger('cubicweb.sqladapter'))
   461 set_log_methods(SQLAdapterMixIn, getLogger('cubicweb.sqladapter'))
   461 
   462 
   462 
   463 
   463 # connection initialization functions ##########################################
   464 # connection initialization functions ##########################################
   464 
   465 
   557     cnx.cursor().execute("pragma foreign_keys = on")
   558     cnx.cursor().execute("pragma foreign_keys = on")
   558 
   559 
   559     import yams.constraints
   560     import yams.constraints
   560     yams.constraints.patch_sqlite_decimal()
   561     yams.constraints.patch_sqlite_decimal()
   561 
   562 
       
   563 
   562 sqlite_hooks = SQL_CONNECT_HOOKS.setdefault('sqlite', [])
   564 sqlite_hooks = SQL_CONNECT_HOOKS.setdefault('sqlite', [])
   563 sqlite_hooks.append(_init_sqlite_connection)
   565 sqlite_hooks.append(_init_sqlite_connection)
   564 
   566 
   565 
   567 
   566 def _init_postgres_connection(cnx):
   568 def _init_postgres_connection(cnx):
   568     cnx.cursor().execute('SET TIME ZONE UTC')
   570     cnx.cursor().execute('SET TIME ZONE UTC')
   569     # commit is needed, else setting are lost if the connection is first
   571     # commit is needed, else setting are lost if the connection is first
   570     # rolled back
   572     # rolled back
   571     cnx.commit()
   573     cnx.commit()
   572 
   574 
       
   575 
   573 postgres_hooks = SQL_CONNECT_HOOKS.setdefault('postgres', [])
   576 postgres_hooks = SQL_CONNECT_HOOKS.setdefault('postgres', [])
   574 postgres_hooks.append(_init_postgres_connection)
   577 postgres_hooks.append(_init_postgres_connection)