def __init__(self, database, timeout=5.0, detect_types=0, isolation_level="", check_same_thread=True, factory=None, cached_statements=100, uri=0): self.__initialized = True db_star = _ffi.new('sqlite3 **') if isinstance(database, unicode): database = database.encode('utf-8') if _lib.SQLITE_OPEN_URI != 0: if uri and _lib.SQLITE_OPEN_URI == 0: raise NotSupportedError("URIs not supported") flags = _lib.SQLITE_OPEN_READWRITE | _lib.SQLITE_OPEN_CREATE if uri: flags |= _lib.SQLITE_OPEN_URI if _lib.sqlite3_open_v2(database, db_star, flags, _ffi.NULL) != _lib.SQLITE_OK: raise OperationalError("Could not open database") else: if _lib.sqlite3_open(database, db_star) != _lib.SQLITE_OK: raise OperationalError("Could not open database") self._db = db_star[0] if timeout is not None: timeout = int(timeout * 1000) # pysqlite2 uses timeout in seconds _lib.sqlite3_busy_timeout(self._db, timeout) self.row_factory = None self.text_factory = _unicode_text_factory self._detect_types = detect_types self.isolation_level = isolation_level self.__cursors = [] self.__cursors_counter = 0 self.__statements = [] self.__statements_counter = 0 self.__rawstatements = set() self._statement_cache = _StatementCache(self, cached_statements) self.__statements_already_committed = [] self.__func_cache = {} self.__aggregates = {} self.__aggregate_instances = {} self.__collations = {} if check_same_thread: self.__thread_ident = threading.get_ident() if not check_same_thread and _lib.sqlite3_libversion_number() < 3003001: raise NotSupportedError("shared connections not available") 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
def __init__( self, database, timeout=5.0, detect_types=0, isolation_level="", check_same_thread=True, factory=None, cached_statements=100, ): self.__initialized = True db_star = _ffi.new("sqlite3 **") if isinstance(database, unicode): database = database.encode("utf-8") if _lib.sqlite3_open(database, db_star) != _lib.SQLITE_OK: raise OperationalError("Could not open database") self._db = db_star[0] if timeout is not None: timeout = int(timeout * 1000) # pysqlite2 uses timeout in seconds _lib.sqlite3_busy_timeout(self._db, timeout) self.row_factory = None self.text_factory = _unicode_text_factory self._detect_types = detect_types self._in_transaction = False self.isolation_level = isolation_level self.__cursors = [] self.__cursors_counter = 0 self.__statements = [] self.__statements_counter = 0 self.__rawstatements = set() self._statement_cache = _StatementCache(self, cached_statements) self.__func_cache = {} self.__aggregates = {} self.__aggregate_instances = {} self.__collations = {} if check_same_thread: self.__thread_ident = _thread_get_ident() 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
def __init__(self, database, timeout=5.0, detect_types=0, isolation_level="", check_same_thread=True, factory=None, cached_statements=100): self.__initialized = True db_star = _ffi.new('sqlite3 **') if isinstance(database, unicode): database = database.encode('utf-8') if _lib.sqlite3_open(database, db_star) != _lib.SQLITE_OK: raise OperationalError("Could not open database") self._db = db_star[0] if timeout is not None: timeout = int(timeout * 1000) # pysqlite2 uses timeout in seconds _lib.sqlite3_busy_timeout(self._db, timeout) self.row_factory = None self.text_factory = _unicode_text_factory self._detect_types = detect_types self._in_transaction = False self.isolation_level = isolation_level self.__cursors = [] self.__cursors_counter = 0 self.__statements = [] self.__statements_counter = 0 self.__rawstatements = set() self._statement_cache = _StatementCache(self, cached_statements) self.__statements_already_committed = [] self.__func_cache = {} self.__aggregates = {} self.__aggregate_instances = {} self.__collations = {} if check_same_thread: self.__thread_ident = _thread_get_ident() 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