本文整理汇总了Python中openspending.model.Dataset.updated_at方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.updated_at方法的具体用法?Python Dataset.updated_at怎么用?Python Dataset.updated_at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openspending.model.Dataset
的用法示例。
在下文中一共展示了Dataset.updated_at方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_fixture
# 需要导入模块: from openspending.model import Dataset [as 别名]
# 或者: from openspending.model.Dataset import updated_at [as 别名]
def load_fixture(name, manager=None):
"""
Load fixture data into the database.
"""
model = model_fixture(name)
dataset = Dataset(model)
dataset.updated_at = datetime.utcnow()
if manager is not None:
dataset.managers.append(manager)
db.session.add(dataset)
db.session.commit()
dataset.generate()
data = data_fixture(name)
reader = csv.DictReader(data)
for row in reader:
entry = convert_types(model["mapping"], row)
dataset.load(entry)
data.close()
dataset.commit()
return dataset
示例2: load_fixture
# 需要导入模块: from openspending.model import Dataset [as 别名]
# 或者: from openspending.model.Dataset import updated_at [as 别名]
def load_fixture(name, manager=None):
"""
Load fixture data into the database.
"""
from openspending.validation.data import convert_types
fh = fixture_file('%s.js' % name)
data = json.load(fh)
fh.close()
dataset = Dataset(data)
dataset.updated_at = datetime.utcnow()
if manager is not None:
dataset.managers.append(manager)
db.session.add(dataset)
db.session.commit()
dataset.generate()
fh = fixture_file('%s.csv' % name)
reader = csv.DictReader(fh)
for row in reader:
entry = convert_types(data['mapping'], row)
dataset.load(entry)
fh.close()
dataset.commit()
return dataset