本文整理汇总了Python中DataModel.new_table方法的典型用法代码示例。如果您正苦于以下问题:Python DataModel.new_table方法的具体用法?Python DataModel.new_table怎么用?Python DataModel.new_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataModel
的用法示例。
在下文中一共展示了DataModel.new_table方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import new_table [as 别名]
def test_create(self):
table_name = 'password_db'
table_model = DataModel(table_name, PasswordData)
table_model.new_table()
vo = PasswordData("your", "your_password")
res = table_model.create(vo)
self.assertEqual(res, 1)
os.remove("./password_db.db")
示例2: test_new_table
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import new_table [as 别名]
def test_new_table(self):
table_name = 'password_db'
table_model = DataModel(table_name, PasswordData)
res = table_model.new_table()
self.assertTrue(res)
res = table_model.new_table()
self.assertFalse(res)
os.remove("./password_db.db")
示例3: test_create_batch_and_retrieve_limit
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import new_table [as 别名]
def test_create_batch_and_retrieve_limit(self):
table_name = 'password_db'
table_model = DataModel(table_name, PasswordData)
table_model.new_table()
l = []
for x in range(0, 5):
l.append(PasswordData('111' + str(x), '222'))
table_model.create_batch(l)
self.assertEqual(table_model.retrieve("name", "1110"), PasswordData('1110', '222'))
self.assertEqual(table_model.retrieve("name", "1114"), PasswordData('1114', '222'))
self.assertEqual(len(table_model.retrieve_limit(1, 3)), 3)
os.remove("./password_db.db")
示例4: test_update
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import new_table [as 别名]
def test_update(self):
table_name = 'password_db'
table_model = DataModel(table_name, PasswordData)
table_model.new_table()
l = []
for x in range(1, 6):
l.append(PasswordData('No' + str(x), str(x)))
table_model.create_batch(l)
row_size = table_model.update("name", "No3", "password", "new_password")
self.assertEqual(row_size, 1)
row_size = table_model.update("name", "No8", "password", "new_password")
self.assertEqual(row_size, 0)
os.remove("./password_db.db")
示例5: test_retrieve
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import new_table [as 别名]
def test_retrieve(self):
table_name = 'password_db'
table_model = DataModel(table_name, PasswordData)
table_model.new_table()
vo1 = PasswordData("your", "your_password")
vo2 = PasswordData("me", "hello")
vo3 = PasswordData("Jack", "lsjdf23dfs")
table_model.create(vo1)
table_model.create(vo2)
table_model.create(vo3)
res = table_model.retrieve("name", "Jack")
obj = PasswordData("Jack", "lsjdf23dfs")
self.assertEqual(res, obj)
res = table_model.retrieve("name", "not_this_name")
self.assertEqual(res, None)
os.remove("./password_db.db")