Example #1
0
    def __init__(self, filename, outputstore=None):
        if filename != ':memory:' and not os.path.exists(filename):
            raise Exception('SQLite file does not exist')

        conn = sqlite3.connect(filename, check_same_thread=False)

        c = conn.cursor()
        c.execute("PRAGMA foreign_keys = ON")
        c.close()

        CrabStoreDB.__init__(self, conn, outputstore)
Example #2
0
File: mysql.py Project: somabc/crab
    def __init__(self, host, database, user, password, outputstore=None):
        """Connects to MySQL and initializes the storage object."""

        conn = mysql.connector.connect(
            host=host, database=database, user=user, password=password,
            time_zone='+00:00')

        CrabStoreDB.__init__(
            self,
            lock=CrabDBLock(
                conn, error_class=_MySQLError,
                cursor_args={'cursor_class': CrabStoreMySQLCursor},
                ping=True),
            outputstore=outputstore)
Example #3
0
    def __init__(self, filename, outputstore=None):
        if filename != ':memory:' and not os.path.exists(filename):
            raise Exception('SQLite file does not exist')

        conn = sqlite3.connect(
            filename, check_same_thread=False,
            detect_types=sqlite3.PARSE_COLNAMES)

        with closing(conn.cursor()) as c:
            c.execute("PRAGMA foreign_keys = ON")

        CrabStoreDB.__init__(
            self,
            lock=CrabDBLock(conn, error_class=sqlite3.DatabaseError),
            outputstore=outputstore)
Example #4
0
    def __init__(self, filename, outputstore=None):
        if filename != ':memory:' and not os.path.exists(filename):
            raise Exception('SQLite file does not exist')

        conn = sqlite3.connect(filename,
                               check_same_thread=False,
                               detect_types=sqlite3.PARSE_COLNAMES)

        with closing(conn.cursor()) as c:
            c.execute("PRAGMA foreign_keys = ON")

        CrabStoreDB.__init__(self,
                             lock=CrabDBLock(
                                 conn, error_class=sqlite3.DatabaseError),
                             outputstore=outputstore)