本文整理汇总了Python中table.Table.get方法的典型用法代码示例。如果您正苦于以下问题:Python Table.get方法的具体用法?Python Table.get怎么用?Python Table.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table.Table
的用法示例。
在下文中一共展示了Table.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import get [as 别名]
def delete(table, where=None):
""" Called for DELETE -queries. """
table = Table.get(table)
rows = _select(table, where)
for row in rows:
table.delete(row)
示例2: insert
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import get [as 别名]
def insert(**kwargs):
""" Called for INSERT -queries. """
table = Table.get(kwargs['table'])
del kwargs['table']
if not 'cols' in kwargs:
kwargs['cols'] = table.cols
table.insert(**kwargs)
示例3: TableTest
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import get [as 别名]
class TableTest(unittest.TestCase):
"""Tests for Table."""
def setUp(self):
self.table = Table('Table', ['Column1', 'Column2'])
self.table.add_row(['a', 'b'])
self.table.add_row(['c', 1])
def test_name(self):
self.assertEquals('Table', self.table.name)
def test_column_names(self):
self.assertEquals(['Column1', 'Column2'], self.table.column_names)
def test_num_columns(self):
self.assertEquals(2, self.table.num_columns)
def test_add_rows(self):
self.table.add_row(['d', 2])
self.assertEquals('d', self.table.get('Column1', 2))
self.assertEquals(2, self.table.get('Column2', 2))
def test_num_rows(self):
self.assertEquals(2, self.table.num_rows)
def test_get_by_index(self):
self.assertEquals('c', self.table.get_by_index(0, 1))
self.assertEquals('b', self.table.get_by_index(1, 0))
def test_get(self):
self.assertEquals('a', self.table.get('Column1', 0))
self.assertEquals(1, self.table.get('Column2', 1))
def test_get_invalid_column(self):
self.assertRaises(ValueError, self.table.get, 'InvalidColumn', 0)
def test_get_invalid_row(self):
self.assertRaises(IndexError, self.table.get, 'Column1', 5)
def test_str(self):
self.assertEquals('Column1,Column2\n' +
'a,b\n' +
'c,1',
str(self.table))
示例4: select
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import get [as 别名]
def select(table, select, where=None, order=None):
""" Called for SELECT -queries. """
table = Table.get(table)
rows = _select(table, where)
if order:
rows = table.sort(order[0], order[1], rows[:])
if select == '*':
for r in rows:
print r.toString()
else:
for r in rows:
print r.toString(select)
示例5: dropIndex
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import get [as 别名]
def dropIndex(**kwargs):
table = Table.get(kwargs['table'])
table.dropIndex(kwargs['index'])
示例6: createIndex
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import get [as 别名]
def createIndex(**kwargs):
table = Table.get(kwargs['table'])
table.createIndex(kwargs['index'], kwargs['cols'][0])