本文整理汇总了Python中dumptruck.DumpTruck.close方法的典型用法代码示例。如果您正苦于以下问题:Python DumpTruck.close方法的具体用法?Python DumpTruck.close怎么用?Python DumpTruck.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dumptruck.DumpTruck
的用法示例。
在下文中一共展示了DumpTruck.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def setUp(self):
self.cleanUp()
h = DumpTruck(dbname=u"/tmp/test.db")
h.save_var(u"birthday", u"November 30, 1888")
h.close()
connection = sqlite3.connect(u"/tmp/test.db")
self.cursor = connection.cursor()
示例2: save_and_check
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def save_and_check(self, dataIn, tableIn, dataOut, tableOut = None, twice = True):
if tableOut == None:
tableOut = quote(tableIn)
# Insert
h = DumpTruck(dbname = '/tmp/test.db')
h.insert(dataIn, tableIn)
h.close()
# Observe with pysqlite
connection=sqlite3.connect('/tmp/test.db')
cursor=connection.cursor()
cursor.execute(u'SELECT * FROM %s' % tableOut)
observed1 = cursor.fetchall()
connection.close()
if twice:
# Observe with DumpTruck
h = DumpTruck(dbname = '/tmp/test.db')
observed2 = h.execute(u'SELECT * FROM %s' % tableOut)
h.close()
#Check
expected1 = dataOut
expected2 = [dataIn] if type(dataIn) in (dict, OrderedDict) else dataIn
self.assertListEqual(observed1, expected1)
self.assertListEqual(observed2, expected2)
示例3: setUp
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def setUp(self):
self.cleanUp()
h = DumpTruck(dbname = u'/tmp/test.db')
h.save_var(u'birthday', u'November 30, 1888')
h.close()
connection=sqlite3.connect(u'/tmp/test.db')
self.cursor=connection.cursor()
示例4: test_no_rows_second_insert
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def test_no_rows_second_insert(self):
"Nothing happens if no rows are inserted to a table that is there."
dt = DumpTruck(dbname="/tmp/test.db")
dt.create_table({"foo": "uhtnh", "bar": "aoue"}, "ninety")
dt.insert([], "ninety")
c = dt.execute("select count(*) as c from ninety")[0]["c"]
dt.close()
self.assertEqual(c, 0)
示例5: test_empty_row_second_insert
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def test_empty_row_second_insert(self):
"An empty row acts like any other row."
dt = DumpTruck(dbname="/tmp/test.db")
dt.create_table({"foo": "uhtnh", "bar": "aoue"}, "nine")
dt.insert({}, "nine")
c = dt.execute("select count(*) as c from nine")[0]["c"]
dt.close()
self.assertEqual(c, 1)
示例6: test_second_insert
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def test_second_insert(self):
"Inserting a second row that is all null adds an empty row."
dt = DumpTruck(dbname="/tmp/test.db")
dt.create_table({"foo": "uhtnh", "bar": "aoue"}, "three")
dt.insert({"foo": None, "bar": None}, "three")
c = dt.execute("select count(*) as c from three")[0]["c"]
dt.close()
self.assertEqual(c, 1)
示例7: test_second_insert
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def test_second_insert(self):
"Inserting a second row that is all null adds an empty row."
dt = DumpTruck(dbname = '/tmp/test.db')
dt.create_table({'foo': 'uhtnh', 'bar': 'aoue'}, 'three')
dt.insert({'foo': None, 'bar': None}, 'three')
c = dt.execute('select count(*) as c from three')[0]['c']
dt.close()
self.assertEqual(c, 1)
示例8: test_empty_row_second_insert
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def test_empty_row_second_insert(self):
"An empty row acts like any other row."
dt = DumpTruck(dbname = '/tmp/test.db')
dt.create_table({'foo': 'uhtnh', 'bar': 'aoue'}, 'nine')
dt.insert({}, 'nine')
c = dt.execute('select count(*) as c from nine')[0]['c']
dt.close()
self.assertEqual(c, 1)
示例9: test_no_rows_second_insert
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def test_no_rows_second_insert(self):
"Nothing happens if no rows are inserted to a table that is there."
dt = DumpTruck(dbname = '/tmp/test.db')
dt.create_table({'foo': 'uhtnh', 'bar': 'aoue'}, 'ninety')
dt.insert([], 'ninety')
c = dt.execute('select count(*) as c from ninety')[0]['c']
dt.close()
self.assertEqual(c, 0)
示例10: savegetvar
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def savegetvar(self, var):
h = DumpTruck(dbname="/tmp/test.db")
h.save_var(u"weird", var)
h.close()
h = DumpTruck(dbname="/tmp/test.db")
t = os.stat("/tmp/test.db").st_mtime
self.assertEqual(h.get_var(u"weird"), var)
h.close()
assert os.stat("/tmp/test.db").st_mtime == t
示例11: savegetvar
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def savegetvar(self, var):
h = DumpTruck(dbname = '/tmp/test.db')
h.save_var(u'weird', var)
h.close()
h = DumpTruck(dbname = '/tmp/test.db')
t=os.stat('/tmp/test.db').st_mtime
self.assertEqual(h.get_var(u'weird'), var)
h.close()
assert os.stat('/tmp/test.db').st_mtime==t
示例12: test_create_table
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def test_create_table(self):
h = DumpTruck(dbname="/tmp/test.db")
h.create_table({"foo": 0, "bar": 1, "baz": 2}, "zombies")
h.close()
connection = sqlite3.connect("/tmp/test.db")
cursor = connection.cursor()
cursor.execute("SELECT foo, bar, baz FROM zombies")
observed = cursor.fetchall()
connection.close()
expected = []
self.assertListEqual(observed, expected)
示例13: test_create_table
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def test_create_table(self):
h = DumpTruck(dbname = '/tmp/test.db')
h.create_table({'foo': 0, 'bar': 1, 'baz': 2}, 'zombies')
h.close()
connection=sqlite3.connect('/tmp/test.db')
cursor=connection.cursor()
cursor.execute('SELECT foo, bar, baz FROM zombies')
observed = cursor.fetchall()
connection.close()
expected = []
self.assertListEqual(observed, expected)
示例14: test_no_rows_first_insert
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def test_no_rows_first_insert(self):
"Nothing happens if no rows are inserted to a table that isn't there."
dt = DumpTruck(dbname = '/tmp/test.db')
dt.insert([], 'ninety')
self.assertSetEqual(dt.tables(), set())
dt.close()
示例15: test_no_rows_create_table
# 需要导入模块: from dumptruck import DumpTruck [as 别名]
# 或者: from dumptruck.DumpTruck import close [as 别名]
def test_no_rows_create_table(self):
"The insert must have a row so the schema can be defined."
dt = DumpTruck(dbname = '/tmp/test.db')
with self.assertRaises(ValueError):
dt.create_table([], 'two')
dt.close()