268 self.get_connection = lambda: ConnectionWrapper(self) |
268 self.get_connection = lambda: ConnectionWrapper(self) |
269 self.check_connection = lambda cnx: cnx |
269 self.check_connection = lambda cnx: cnx |
270 def pool_reset(cnx): |
270 def pool_reset(cnx): |
271 cnx.close() |
271 cnx.close() |
272 self.pool_reset = pool_reset |
272 self.pool_reset = pool_reset |
|
273 self.create_eid = self.__create_eid_sqlite |
273 |
274 |
274 @property |
275 @property |
275 def _sqlcnx(self): |
276 def _sqlcnx(self): |
276 # XXX: sqlite connections can only be used in the same thread, so |
277 # XXX: sqlite connections can only be used in the same thread, so |
277 # create a new one each time necessary. If it appears to be time |
278 # create a new one each time necessary. If it appears to be time |
726 # we don't want on commit drop, this may cause problem when |
727 # we don't want on commit drop, this may cause problem when |
727 # running with an ldap source, and table will be deleted manually any way |
728 # running with an ldap source, and table will be deleted manually any way |
728 # on commit |
729 # on commit |
729 sql = self.dbhelper.sql_temporary_table(table, schema, False) |
730 sql = self.dbhelper.sql_temporary_table(table, schema, False) |
730 self.doexec(session, sql) |
731 self.doexec(session, sql) |
|
732 |
|
733 def __create_eid_sqlite(self, session): |
|
734 self._eid_creation_lock.acquire() |
|
735 try: |
|
736 for sql in self.dbhelper.sqls_increment_sequence('entities_id_seq'): |
|
737 cursor = self.doexec(session, sql) |
|
738 return cursor.fetchone()[0] |
|
739 finally: |
|
740 self._eid_creation_lock.release() |
|
741 |
731 |
742 |
732 def create_eid(self, session): |
743 def create_eid(self, session): |
733 self.debug('create eid') |
744 self.debug('create eid') |
734 # lock needed to prevent 'Connection is busy with results for another command (0)' errors with SQLServer |
745 # lock needed to prevent 'Connection is busy with results for another command (0)' errors with SQLServer |
735 self._eid_creation_lock.acquire() |
746 self._eid_creation_lock.acquire() |