Пример #1
0
 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",))
Пример #2
0
 def default_conn_ctx(self):
     if self.in_memory:
         return  monetdbe.connect('in-memory', autocommit=True)
     ctx = PyMonetDBConnectionContext()
     return ctx
Пример #3
0
 def test_ClosedCurExecute(self):
     con = monetdbe.connect(":memory:")
     cur = con.cursor()
     con.close()
     with self.assertRaises(monetdbe.ProgrammingError):
         cur.execute("select 4")
Пример #4
0
 def test_ClosedCall(self):
     con = monetdbe.connect(":memory:")
     con.close()
     with self.assertRaises(monetdbe.ProgrammingError):
         con()
Пример #5
0
 def test_ConnectionExecute(self):
     con = monetdbe.connect(":memory:")
     result = con.execute("select 5").fetchone()[0]
     self.assertEqual(result, 5, "Basic test of Connection.execute")
Пример #6
0
 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")
Пример #7
0
 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;")
Пример #8
0
 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"
Пример #9
0
 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)")
Пример #10
0
 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)")
Пример #11
0
 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')
Пример #12
0
 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)
Пример #13
0
 def setUp(self):
     self.cx = monetdbe.connect(":memory:")
     self.cu = self.cx.cursor()
Пример #14
0
 def test_empty_colnames(self):
     # empty colnames
     with pytest.raises(monetdbe.DatabaseError):
         monetdbe.connect().cursor().create('pylite07', {'': []})
Пример #15
0
 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.')
Пример #16
0
 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)
Пример #17
0
 def setUp(self) -> None:
     self.con = monetdbe.connect()