예제 #1
0
    def __init__(self, cookie, pathname=None, seed=None, version=None,
            compatible=None):
        if cookie != bayesdb_open_cookie:
            raise ValueError('Do not construct BayesDB objects directly!')
        if pathname is None:
            pathname = ":memory:"
        self._sqlite3 = apsw.Connection(pathname)
        self.txn_depth = 0
        self.metamodels = {}
        self.tracer = None
        self.sql_tracer = None
        self.cache = None
        self.temptable = 0
        self.qid = 0
        if seed is None:
            seed = struct.pack('<QQQQ', 0, 0, 0, 0)
        self._prng = weakprng.weakprng(seed)
        pyrseed = self._prng.weakrandom32()
        self._py_prng = random.Random(pyrseed)
        nprseed = [self._prng.weakrandom32() for _ in range(4)]
        self._np_prng = numpy.random.RandomState(nprseed)
        schema.bayesdb_install_schema(self._sqlite3, version=version,
            compatible=compatible)
        bqlfn.bayesdb_install_bql(self._sqlite3, self)

        # Cache an empty cursor for convenience.
        empty_cursor = self._sqlite3.cursor()
        empty_cursor.execute('')
        self._empty_cursor = bql.BayesDBCursor(self, empty_cursor)
예제 #2
0
    def __init__(self,
                 cookie,
                 pathname=None,
                 seed=None,
                 version=None,
                 compatible=None):
        if cookie != bayesdb_open_cookie:
            raise ValueError('Do not construct BayesDB objects directly!')
        if pathname is None:
            pathname = ":memory:"
        self._sqlite3 = apsw.Connection(pathname)
        self.txn_depth = 0
        self.metamodels = {}
        self.tracer = None
        self.sql_tracer = None
        self.cache = None
        self.temptable = 0
        self.qid = 0
        if seed is None:
            seed = struct.pack('<QQQQ', 0, 0, 0, 0)
        self._prng = weakprng.weakprng(seed)
        pyrseed = self._prng.weakrandom32()
        self._py_prng = random.Random(pyrseed)
        nprseed = [self._prng.weakrandom32() for _ in range(4)]
        self._np_prng = numpy.random.RandomState(nprseed)
        schema.bayesdb_install_schema(self._sqlite3,
                                      version=version,
                                      compatible=compatible)
        bqlfn.bayesdb_install_bql(self._sqlite3, self)

        # Cache an empty cursor for convenience.
        empty_cursor = self._sqlite3.cursor()
        empty_cursor.execute('')
        self._empty_cursor = bql.BayesDBCursor(self, empty_cursor)
예제 #3
0
    def __init__(self, cookie, pathname=None, seed=None, version=None,
            compatible=None):
        if cookie != bayesdb_open_cookie:
            raise ValueError('Do not construct BayesDB objects directly!')
        if pathname is None:
            pathname = ":memory:"
        # isolation_level=None actually means that the sqlite3 module
        # will not randomly begin and commit transactions where we
        # didn't ask it to.
        self.sqlite3 = sqlite3.connect(pathname, isolation_level=None)
        self.txn_depth = 0
        self.metamodels = {}
        self.tracer = None
        self.sql_tracer = None
        self.cache = None
        self.temptable = 0
        self.qid = 0
        if seed is None:
            seed = struct.pack('<QQQQ', 0, 0, 0, 0)
        self._prng = weakprng.weakprng(seed)
        pyrseed = self._prng.weakrandom32()
        self._py_prng = random.Random(pyrseed)
        nprseed = [self._prng.weakrandom32() for _ in range(4)]
        self._np_prng = numpy.random.RandomState(nprseed)
        schema.bayesdb_install_schema(self.sqlite3, version=version,
            compatible=compatible)
        bqlfn.bayesdb_install_bql(self.sqlite3, self)

        # Cache an empty cursor for convenience.
        self.empty_cursor = bql.BayesDBCursor(self, self.sqlite3.execute(''))
예제 #4
0
    def __init__(self,
                 cookie,
                 pathname=None,
                 seed=None,
                 version=None,
                 compatible=None):
        if cookie != bayesdb_open_cookie:
            raise ValueError('Do not construct BayesDB objects directly!')
        if pathname is None:
            pathname = ":memory:"
        self.pathname = pathname
        self._sqlite3 = apsw.Connection(pathname)
        self._txn_depth = 0  # managed in txn.py
        self._cache = None  # managed in txn.py
        self.metamodels = {}
        self.tracer = None
        self.sql_tracer = None
        self.temptable = 0
        self.qid = 0
        if seed is None:
            seed = struct.pack('<QQQQ', 0, 0, 0, 0)
        self._prng = weakprng.weakprng(seed)
        pyrseed = self._prng.weakrandom32()
        self._py_prng = random.Random(pyrseed)
        nprseed = [self._prng.weakrandom32() for _ in range(4)]
        self._np_prng = numpy.random.RandomState(nprseed)

        # Set up or check the permanent schema on disk.
        schema.bayesdb_install_schema(self,
                                      version=version,
                                      compatible=compatible)

        # Set up the in-memory BQL functions and virtual tables that
        # need not have storage on disk.
        bqlfn.bayesdb_install_bql(self._sqlite3, self)
        self._sqlite3.createmodule('bql_mutinf', bqlvtab.MutinfModule(self))
        self._sqlite3.cursor().execute(
            'create virtual table temp.bql_mutinf using bql_mutinf')

        # Cache an empty cursor for convenience.
        empty_cursor = self._sqlite3.cursor()
        empty_cursor.execute('')
        self._empty_cursor = bql.BayesDBCursor(self, empty_cursor)
예제 #5
0
    def __init__(self, cookie, pathname=None, seed=None, version=None,
            compatible=None):
        if cookie != bayesdb_open_cookie:
            raise ValueError('Do not construct BayesDB objects directly!')
        if pathname is None:
            pathname = ":memory:"
        self.pathname = pathname
        self._sqlite3 = apsw.Connection(pathname)
        self._txn_depth = 0     # managed in txn.py
        self._cache = None      # managed in txn.py
        self.backends = {}
        self.tracer = None
        self.sql_tracer = None
        self.temptable = 0
        self.qid = 0
        if seed is None:
            seed = struct.pack('<QQQQ', 0, 0, 0, 0)
        self._prng = weakprng.weakprng(seed)
        pyrseed = self._prng.weakrandom32()
        self._py_prng = random.Random(pyrseed)
        nprseed = [self._prng.weakrandom32() for _ in range(4)]
        self._np_prng = numpy.random.RandomState(nprseed)

        # Set up or check the permanent schema on disk.
        schema.bayesdb_install_schema(self, version=version,
            compatible=compatible)

        # Set up the in-memory BQL functions and virtual tables that
        # need not have storage on disk.
        bqlfn.bayesdb_install_bql(self._sqlite3, self)
        self._sqlite3.createmodule('bql_mutinf', bqlvtab.MutinfModule(self))
        self._sqlite3.cursor().execute(
            'create virtual table temp.bql_mutinf using bql_mutinf')

        # Set up math utilities.
        bqlmath.bayesdb_install_bqlmath(self._sqlite3, self)

        # Cache an empty cursor for convenience.
        empty_cursor = self._sqlite3.cursor()
        empty_cursor.execute('')
        self._empty_cursor = bql.BayesDBCursor(self, empty_cursor)
예제 #6
0
    def __init__(self, cookie, pathname=None):
        if cookie != bayesdb_open_cookie:
            raise ValueError('Do not construct BayesDB objects directly!')
        if pathname is None:
            pathname = ":memory:"
        # isolation_level=None actually means that the sqlite3 module
        # will not randomly begin and commit transactions where we
        # didn't ask it to.
        self.sqlite3 = sqlite3.connect(pathname, isolation_level=None)
        self.txn_depth = 0
        self.metamodels = {}
        self.tracer = None
        self.sql_tracer = None
        self.cache = None
        self.temptable = 0
        self.qid = 0
        schema.bayesdb_install_schema(self.sqlite3)
        bqlfn.bayesdb_install_bql(self.sqlite3, self)

        # Cache an empty cursor for convenience.
        self.empty_cursor = bql.BayesDBCursor(self, self.sqlite3.execute(''))