Changeset: 3537ff223ff3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3537ff223ff3
Modified Files:
clients/python3/monetdb/sql/cursors.py
clients/python3/monetdb/sql/monetize.py
clients/python3/test/capabilities.py
Branch: default
Log Message:
ported py2 changes to py3
diffs (87 lines):
diff --git a/clients/python3/monetdb/sql/cursors.py
b/clients/python3/monetdb/sql/cursors.py
--- a/clients/python3/monetdb/sql/cursors.py
+++ b/clients/python3/monetdb/sql/cursors.py
@@ -157,6 +157,9 @@ class Cursor:
will be bound to variables in the operation.
"""
+ if not self.connection:
+ self.__exception_handler(ProgrammingError, "cursor is closed")
+
# clear message history
self.messages = []
diff --git a/clients/python3/monetdb/sql/monetize.py
b/clients/python3/monetdb/sql/monetize.py
--- a/clients/python3/monetdb/sql/monetize.py
+++ b/clients/python3/monetdb/sql/monetize.py
@@ -16,12 +16,15 @@
# All Rights Reserved.
"""
-functions for converting python objects to monetdb SQL format
+functions for converting python objects to monetdb SQL format. If you want
+to add support for a specific type you should add a function as a value to
+the mapping dict and the datatype as key.
"""
import datetime
import logging
import decimal
+from monetdb.exceptions import ProgrammingError
logger = logging.getLogger("monetdb")
diff --git a/clients/python3/test/capabilities.py
b/clients/python3/test/capabilities.py
--- a/clients/python3/test/capabilities.py
+++ b/clients/python3/test/capabilities.py
@@ -24,10 +24,8 @@
"""
from time import time
-import array
import unittest
-import sys
-
+from monetdb.exceptions import ProgrammingError
class DatabaseTest(unittest.TestCase):
@@ -325,7 +323,6 @@ class DatabaseTest(unittest.TestCase):
('col1 TINYINT',),
generator)
-
def test_small_CHAR(self):
# Character data
def generator(row,col):
@@ -337,7 +334,6 @@ class DatabaseTest(unittest.TestCase):
('col1 char(1)','col2 char(1)'),
generator)
-
def test_description(self):
self.table = self.new_table_name()
shouldbe = [
@@ -353,8 +349,6 @@ class DatabaseTest(unittest.TestCase):
finally:
self.cursor.execute('drop table %s' % (self.table))
-
-
def test_bigresult(self):
self.cursor.execute('select count(*) from tables')
r = self.cursor.fetchone()
@@ -364,3 +358,13 @@ class DatabaseTest(unittest.TestCase):
r = self.cursor.fetchall()
self.assertEqual(len(r), n**2)
+ def test_closecur(self):
+ self.cursor.close()
+ self.assertRaises(ProgrammingError, self.cursor.execute, "select *
from tables")
+ self.cursor = self.connection.cursor()
+
+ def test_customtype(self):
+ t = ["list", "test"]
+ self.assertRaises(ProgrammingError, self.db_module.monetize.convert, t)
+ self.db_module.monetize.mapping[list] = str
+ self.assertEqual(self.db_module.monetize.convert(t), "['list',
'test']")
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list