def open_new_db(self, filename, static_filename):
        self.filename = filename
        self.static_filename = static_filename

        ##adbapi.noisy = True  # and add log.startLogging(sys.stdout) somewhere

        # since we're using apsw which is not technically DBAPI compliant 
        # I've created this wrapper class to make it act like one.
        adbapi.connectionFactory = apsw_connection.ApswConnection

        # if there is a static db ...
        def attach_static_db(conn):
            if static_filename != None and os.path.exists(static_filename):
                cur = conn.cursor()
                try:
                    result = cur.execute( static_filename % "ATTACH DATABASE '%s' AS static;")
                except Exception as e:
                    logging.info("SqlConnections: ERROR Failed to attach static db '%s': %s", static_filename, str(e))

        # Open a connection pool for writing (one thread)...

        self.writer_dbpool = adbapi.ConnectionPool('apsw_connection', filename, 
                                                   cp_openfun=attach_static_db,
                                                   cp_min=1, cp_max=1)
                                                   
        self.writer_dbpool.connectionFactory = apsw_connection.ApswConnection

        # ...and one for reading (multiple threads).

        self.reader_dbpool = adbapi.ConnectionPool('apsw_connection', filename, 
                                                   cp_openfun=attach_static_db)

        self.reader_dbpool.connectionFactory = apsw_connection.ApswConnection


        # Preload list of tables already in db.

        self.reader_dbpool.runInteraction(self.preload_tables_list)
dataset/ETHPy150Open MediaMath/qasino/lib/sqlite_backend.py/SqlConnections.open_new_db/swapped operands of `%`