def setUp(self): self.cx = monetdbe.connect(":memory:") cu = self.cx.cursor() cu.execute("create table test(id integer primary key, name text)") cu.execute("insert into test(name) values (?)", ("foo",))
def default_conn_ctx(self): if self.in_memory: return monetdbe.connect('in-memory', autocommit=True) ctx = PyMonetDBConnectionContext() return ctx
def test_ClosedCurExecute(self): con = monetdbe.connect(":memory:") cur = con.cursor() con.close() with self.assertRaises(monetdbe.ProgrammingError): cur.execute("select 4")
def test_ClosedCall(self): con = monetdbe.connect(":memory:") con.close() with self.assertRaises(monetdbe.ProgrammingError): con()
def test_ConnectionExecute(self): con = monetdbe.connect(":memory:") result = con.execute("select 5").fetchone()[0] self.assertEqual(result, 5, "Basic test of Connection.execute")
def test_ConnectionExecutescript(self): con = monetdbe.connect(":memory:") con.executescript("create table test(foo); insert into test(foo) values (5);") result = con.execute("select foo from test").fetchone()[0] self.assertEqual(result, 5, "Basic test of Connection.executescript")
def test_ScriptErrorNormal(self): con = monetdbe.connect(":memory:") cur = con.cursor() with self.assertRaises(monetdbe.OperationalError): cur.executescript("create table test(sadfsadfdsa); select foo from hurz;")
def test_regular_selection(self): con = monetdbe.connect() monetdbe.sql('CREATE TABLE pylite00 (i INTEGER)', client=con) con.execute('INSERT INTO pylite00 VALUES (1), (2), (3), (4), (5)') result = con.execute('SELECT * FROM pylite00').fetchall() assert len(result['i']) == 5, "Incorrect result"
def setUp(self): self.con = monetdbe.connect(":memory:") self.cur = self.con.cursor() self.cur.execute("create table test(id integer primary key, name text, bin binary, ratio number, ts timestamp)")
def test_ScriptSyntaxError(self): con = monetdbe.connect(":memory:") cur = con.cursor() with self.assertRaises(monetdbe.OperationalError): cur.executescript("create table test(x); asdf; create table test2(x)")
def test_SameThreadErrorOnOldVersion(self): with self.assertRaises(monetdbe.NotSupportedError) as cm: monetdbe.connect(':memory:', check_same_thread=False) self.assertEqual(str(cm.exception), 'shared connections not available')
def test_FailedOpen(self): YOU_CANNOT_OPEN_THIS = "/foo/bar/bla/23534/mydb.db" with self.assertRaises(monetdbe.OperationalError): con = monetdbe.connect(YOU_CANNOT_OPEN_THIS)
def setUp(self): self.cx = monetdbe.connect(":memory:") self.cu = self.cx.cursor()
def test_empty_colnames(self): # empty colnames with pytest.raises(monetdbe.DatabaseError): monetdbe.connect().cursor().create('pylite07', {'': []})
def test_CursorExecutescriptAsBytes(self): con = monetdbe.connect(":memory:") cur = con.cursor() with self.assertRaises(ValueError) as cm: cur.executescript(b"create table test(foo); insert into test(foo) values (5);") self.assertEqual(str(cm.exception), 'script argument must be unicode.')
def test_invalid_key_dict(self): # dictionary with invalid keys d = dict() d[33] = 44 with pytest.raises(monetdbe.ProgrammingError): monetdbe.connect().cursor().create('pylite08', d)
def setUp(self) -> None: self.con = monetdbe.connect()