コード例 #1
0
ファイル: test_copy.py プロジェクト: simudream/pg8000
 def testCopyFromWithError(self):
     try:
         cursor = self.db.cursor()
         stream = BytesIO(b("f1Xf2\n\n1XY1Y\n"))
         cursor.execute(
             "COPY t1 (f1, f2) FROM STDIN WITH DELIMITER 'X' CSV HEADER "
             "QUOTE AS 'Y' FORCE NOT NULL f1",
             stream=stream)
         self.assertTrue(False, "Should have raised an exception")
     except:
         args_dict = {
             0: u('ERROR'),
             1: u('22P02'),
             2: u('invalid input syntax for integer: ""'),
             3: u('COPY t1, line 2, column f1: ""'),
             4: u('numutils.c'),
             6: u('pg_atoi'),
             7: u(''),
             8: u('')
         }
         args = exc_info()[1].args
         for k, v in iteritems(args_dict):
             self.assertEqual(args[k], v)
     finally:
         cursor.close()
コード例 #2
0
ファイル: test_copy.py プロジェクト: simudream/pg8000
 def testCopyFromWithError(self):
     try:
         cursor = self.db.cursor()
         stream = BytesIO(b("f1Xf2\n\n1XY1Y\n"))
         cursor.execute(
             "COPY t1 (f1, f2) FROM STDIN WITH DELIMITER 'X' CSV HEADER " "QUOTE AS 'Y' FORCE NOT NULL f1",
             stream=stream,
         )
         self.assertTrue(False, "Should have raised an exception")
     except:
         args_dict = {
             0: u("ERROR"),
             1: u("22P02"),
             2: u('invalid input syntax for integer: ""'),
             3: u('COPY t1, line 2, column f1: ""'),
             4: u("numutils.c"),
             6: u("pg_atoi"),
             7: u(""),
             8: u(""),
         }
         args = exc_info()[1].args
         for k, v in iteritems(args_dict):
             self.assertEqual(args[k], v)
     finally:
         cursor.close()
コード例 #3
0
ファイル: test_query.py プロジェクト: nad2000/pg8000
 def testUnicodeQuery(self):
     try:
         cursor = db.cursor()
         cursor.execute(
             u("CREATE TEMPORARY TABLE \u043c\u0435\u0441\u0442\u043e "
               "(\u0438\u043c\u044f VARCHAR(50), "
               "\u0430\u0434\u0440\u0435\u0441 VARCHAR(250))"))
     finally:
         cursor.close()
         db.commit()
コード例 #4
0
 def testUnicodeQuery(self):
     try:
         cursor = self.db.cursor()
         cursor.execute(
             u(
                 "CREATE TEMPORARY TABLE \u043c\u0435\u0441\u0442\u043e "
                 "(\u0438\u043c\u044f VARCHAR(50), "
                 "\u0430\u0434\u0440\u0435\u0441 VARCHAR(250))"))
     finally:
         cursor.close()
         self.db.commit()