예제 #1
0
 def _check_thread(self):
     if not hasattr(self, 'thread_ident'):
         return
     if self.thread_ident != thread_get_ident():
         raise ProgrammingError(
             "SQLite objects created in a thread can only be used in that same thread."
             "The object was created in thread id %d and this is thread id %d",
             self.thread_ident, thread_get_ident())
예제 #2
0
 def _check_thread(self):
     if not hasattr(self, 'thread_ident'):
         return
     if self.thread_ident != thread_get_ident():
         raise ProgrammingError(
             "SQLite objects created in a thread can only be used in that same thread."
             "The object was created in thread id %d and this is thread id %d",
             self.thread_ident, thread_get_ident())
예제 #3
0
파일: dbapi2.py 프로젝트: enyst/plexnet
    def __init__(self, database, isolation_level="", detect_types=0, timeout=None, *args, **kwargs):
        self.db = c_void_p()
        if sqlite.sqlite3_open(database, byref(self.db)) != SQLITE_OK:
            raise OperationalError("Could not open database")
        if timeout is not None:
            timeout = int(timeout * 1000) # pysqlite2 uses timeout in seconds
            sqlite.sqlite3_busy_timeout(self.db, timeout)

        self.text_factory = lambda x: unicode(x, "utf-8")
        self.closed = False
        self.statements = []
        self.statement_counter = 0
        self.row_factory = None
        self._isolation_level = isolation_level
        self.detect_types = detect_types

        self.Error = Error
        self.Warning = Warning
        self.InterfaceError = InterfaceError
        self.DatabaseError = DatabaseError
        self.InternalError = InternalError
        self.OperationalError = OperationalError
        self.ProgrammingError = ProgrammingError
        self.IntegrityError = IntegrityError
        self.DataError = DataError
        self.NotSupportedError = NotSupportedError

        self.func_cache = {}
        self.thread_ident = thread_get_ident()
예제 #4
0
    def __init__(self, database, isolation_level="", detect_types=0, timeout=None, cached_statements=None, factory=None):
        self.db = c_void_p()
        if sqlite.sqlite3_open(database, byref(self.db)) != SQLITE_OK:
            raise OperationalError("Could not open database")
        if timeout is not None:
            timeout = int(timeout * 1000) # pysqlite2 uses timeout in seconds
            sqlite.sqlite3_busy_timeout(self.db, timeout)

        self.text_factory = unicode_text_factory
        self.closed = False
        self.statements = []
        self.statement_counter = 0
        self.row_factory = None
        self._isolation_level = isolation_level
        self.detect_types = detect_types

        self.cursors = []

        self.Error = Error
        self.Warning = Warning
        self.InterfaceError = InterfaceError
        self.DatabaseError = DatabaseError
        self.InternalError = InternalError
        self.OperationalError = OperationalError
        self.ProgrammingError = ProgrammingError
        self.IntegrityError = IntegrityError
        self.DataError = DataError
        self.NotSupportedError = NotSupportedError

        self.func_cache = {}
        self._aggregates = {}
        self.aggregate_instances = {}
        self._collations = {}
        self.thread_ident = thread_get_ident()
예제 #5
0
    def __init__(
        self,
        database,
        timeout=5.0,
        detect_types=0,
        isolation_level="",
        check_same_thread=True,
        factory=None,
        cached_statements=100,
    ):
        self.db = c_void_p()
        if sqlite.sqlite3_open(database, byref(self.db)) != SQLITE_OK:
            raise OperationalError("Could not open database")
        if timeout is not None:
            timeout = int(timeout * 1000)  # pysqlite2 uses timeout in seconds
            sqlite.sqlite3_busy_timeout(self.db, timeout)

        self.text_factory = unicode_text_factory
        self.closed = False
        self.statements = []
        self.statement_counter = 0
        self.row_factory = None
        self._isolation_level = isolation_level
        self.detect_types = detect_types

        self.cursors = []

        self.Error = Error
        self.Warning = Warning
        self.InterfaceError = InterfaceError
        self.DatabaseError = DatabaseError
        self.InternalError = InternalError
        self.OperationalError = OperationalError
        self.ProgrammingError = ProgrammingError
        self.IntegrityError = IntegrityError
        self.DataError = DataError
        self.NotSupportedError = NotSupportedError

        self.func_cache = {}
        self._aggregates = {}
        self.aggregate_instances = {}
        self._collations = {}
        if check_same_thread:
            self.thread_ident = thread_get_ident()
예제 #6
0
파일: abstract.py 프로젝트: decryptus/dwho
    def db(self, value):
        thread_id = thread_get_ident()
        if thread_id not in self._db:
            self._db[thread_id] = {}

        self._db[thread_id] = value
예제 #7
0
파일: abstract.py 프로젝트: decryptus/dwho
    def db(self):
        thread_id = thread_get_ident()
        if thread_id not in self._db:
            self._db[thread_id] = {}

        return self._db[thread_id]