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