示例#1
0
文件: sqldf.py 项目: airtoxin/pysqldf
 def test_write_table_method(self):
     df = DataFrame([[1, 2], [3, 4]], columns=["col1", "col2"])
     sqldf = SQLDF(locals())
     sqldf._write_table("tbl", df)
     # table created
     cursor = sqldf.conn.cursor()
     sq_type, name, tbl_name, rootpage, sql = list(
         cursor.execute("select * from sqlite_master where type='table';"))[0]
     self.assertEqual(name, "tbl")
示例#2
0
文件: sqldf.py 项目: paudan/pysqldf
 def test_write_table_method(self):
     df = DataFrame([[1, 2], [3, 4]], columns=["col1", "col2"])
     sqldf = SQLDF(locals())
     sqldf._write_table("tbl", df)
     # table created
     cursor = sqldf.conn.cursor()
     sq_type, name, tbl_name, rootpage, sql = list(
         cursor.execute(
             "select * from sqlite_master where type='table';"))[0]
     self.assertEqual(name, "tbl")
示例#3
0
文件: sqldf.py 项目: airtoxin/pysqldf
 def test_write_table_method_garbage_table(self):
     df = [[1, 2], [3, [4]]]
     sqldf = SQLDF(locals())
     self.assertRaises(Exception, lambda: sqldf._write_table("tbl", df))
     # table destroyed
     cursor = sqldf.conn.cursor()
     tablemaster = list(cursor.execute("select * from sqlite_master where type='table';"))
     self.assertEqual(tablemaster, [])
示例#4
0
文件: sqldf.py 项目: paudan/pysqldf
 def test_write_table_method_garbage_table(self):
     df = [[1, 2], [3, [4]]]
     sqldf = SQLDF(locals())
     self.assertRaises(Exception, lambda: sqldf._write_table("tbl", df))
     # table destroyed
     cursor = sqldf.conn.cursor()
     tablemaster = list(
         cursor.execute("select * from sqlite_master where type='table';"))
     self.assertEqual(tablemaster, [])
示例#5
0
文件: sqldf.py 项目: paudan/pysqldf
 def test_write_table_method_col_with_right_bracket(self):
     df = DataFrame([[1]], columns=["co)l"])
     sqldf = SQLDF(locals())
     self.assertRaises(Exception, lambda: sqldf._write_table("tbl", df))
示例#6
0
文件: sqldf.py 项目: airtoxin/pysqldf
 def test_write_table_method_col_with_right_bracket(self):
     df = DataFrame([[1]], columns=["co)l"])
     sqldf = SQLDF(locals())
     self.assertRaises(Exception, lambda: sqldf._write_table("tbl", df))