def __init__(self, opts, *args, **kwargs): """ Initialize the connection pool. """ self.opts = opts try: adbapi.ConnectionPool.__init__(self, *args, **kwargs) except dbapi2.DatabaseError as e: raise DatabaseAccessError( 'Error initializing u1db connection pool: %s' % str(e)) # all u1db connections, hashed by thread-id self._u1dbconnections = {} # The replica uid, primed by the connections on init. self.replica_uid = ProxyBase(None) try: conn = self.connectionFactory( self, init_u1db=True) replica_uid = conn._u1db._real_replica_uid setProxiedObject(self.replica_uid, replica_uid) except DatabaseAccessError as e: self.threadpool.stop() raise DatabaseAccessError( "Error initializing connection factory: %s" % str(e))
def _initialize_main_db(self): try: self._db_handle = initialize_sqlcipher_db(self._opts, check_same_thread=False) self._real_replica_uid = None self._ensure_schema() self.set_document_factory(soledad_doc_factory) except sqlcipher_dbapi2.DatabaseError as e: raise DatabaseAccessError(str(e))
def __init__(self, pool, sync_enc_pool, init_u1db=False): """ :param pool: The pool of connections to that owns this connection. :type pool: adbapi.ConnectionPool :param init_u1db: Wether the u1db database should be initialized. :type init_u1db: bool """ self.init_u1db = init_u1db self._sync_enc_pool = sync_enc_pool try: adbapi.Connection.__init__(self, pool) except DatabaseError: raise DatabaseAccessError('Could not open sqlcipher database')
def __init__(self, pool, init_u1db=False): """ :param pool: The pool of connections to that owns this connection. :type pool: adbapi.ConnectionPool :param init_u1db: Wether the u1db database should be initialized. :type init_u1db: bool """ self.init_u1db = init_u1db try: adbapi.Connection.__init__(self, pool) except dbapi2.DatabaseError as e: raise DatabaseAccessError( 'Error initializing connection to sqlcipher database: %s' % str(e))
def __init__(self, *args, **kwargs): """ Initialize the connection pool. """ # extract soledad-specific objects from keyword arguments self.opts = kwargs.pop("opts") self._sync_enc_pool = kwargs.pop("sync_enc_pool") try: adbapi.ConnectionPool.__init__(self, *args, **kwargs) except DatabaseError: raise DatabaseAccessError('Could not open sqlcipher database') # all u1db connections, hashed by thread-id self._u1dbconnections = {} # The replica uid, primed by the connections on init. self.replica_uid = ProxyBase(None) conn = self.connectionFactory(self, self._sync_enc_pool, init_u1db=True) replica_uid = conn._u1db._real_replica_uid setProxiedObject(self.replica_uid, replica_uid)