当前位置: 首页>>代码示例>>Python>>正文


Python ExportSchema.save方法代码示例

本文整理汇总了Python中couchexport.models.ExportSchema.save方法的典型用法代码示例。如果您正苦于以下问题:Python ExportSchema.save方法的具体用法?Python ExportSchema.save怎么用?Python ExportSchema.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在couchexport.models.ExportSchema的用法示例。


在下文中一共展示了ExportSchema.save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_new_checkpoint

# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import save [as 别名]
 def create_new_checkpoint(self):
     checkpoint = ExportSchema(
         schema=self.get_latest_schema(),
         timestamp=self.timestamp,
         index=self.schema_index,
     )
     checkpoint.save()
     return checkpoint
开发者ID:nnestle,项目名称:commcare-hq,代码行数:10,代码来源:export.py

示例2: create_basic_form_checkpoint

# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import save [as 别名]
def create_basic_form_checkpoint(index):
    checkpoint = ExportSchema(
        schema=BASIC_FORM_SCHEMA,
        timestamp=datetime(1970, 1, 1),
        index=index,
    )
    checkpoint.save()
    return checkpoint
开发者ID:puttarajubr,项目名称:commcare-hq,代码行数:10,代码来源:views.py

示例3: testSaveAndLoad

# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import save [as 别名]
 def testSaveAndLoad(self):
     index = ["foo", 2]
     schema = ExportSchema(seq=5, index=index)
     inner = {"dict": {"bar": 1, "baz": [2,3]},
              "list": ["foo", "bar"],
              "dictlist": [{"bip": 1, "bop": "blah"},
                           {"bip": 2, "bop": "blah2"}],
              "item": "yoyoyo"}
     schema.schema = inner
     schema.save()
     back = ExportSchema.get(schema.get_id)
     self.assertEqual(inner, back.schema)
     self.assertEqual(index, back.index)
开发者ID:wbnigeria,项目名称:couchexport,代码行数:15,代码来源:tests.py

示例4: test_get_all_checkpoints

# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import save [as 别名]
    def test_get_all_checkpoints(self):
        index = ["mydomain", "myxmlns"]
        self.addCleanup(lambda: [cp.delete() for cp in ExportSchema.get_all_checkpoints(index)])

        schema1 = ExportSchema(index=index, timestamp=datetime.utcnow())
        schema1.save()
        schema1_prime, = list(ExportSchema.get_all_checkpoints(index))
        self.assert_docs_equal(schema1_prime, schema1)
        schema2 = ExportSchema(index=index, timestamp=datetime.utcnow())
        schema2.save()
        schema1_prime, schema2_prime = list(ExportSchema.get_all_checkpoints(index))
        self.assert_docs_equal(schema1_prime, schema1)
        self.assert_docs_equal(schema2_prime, schema2)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:15,代码来源:test_schema.py

示例5: build_latest_schema

# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import save [as 别名]
def build_latest_schema(schema_index):
    """
    Build a schema, directly from the index. Also creates a saved checkpoint.
    """
    from couchexport.export import ExportConfiguration
    db = Database(settings.COUCH_DATABASE)
    current_seq = db.info()["update_seq"]
    previous_export = ExportSchema.last(schema_index)
    config = ExportConfiguration(get_db(), schema_index, 
                                 previous_export=previous_export)
    schema = get_schema_new(config)
    if not schema:
        return None
    updated_checkpoint = ExportSchema(seq=current_seq, schema=schema, 
                                      index=schema_index)
    updated_checkpoint.save()
    return updated_checkpoint
开发者ID:wbnigeria,项目名称:couchexport,代码行数:19,代码来源:schema.py

示例6: export

# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import save [as 别名]
def export(
    schema_index,
    file,
    format=Format.XLS_2007,
    previous_export_id=None,
    filter=None,
    max_column_size=2000,
    separator="|",
):
    """
    Exports data from couch documents matching a given tag to a file. 
    Returns true if it finds data, otherwise nothing
    """

    previous_export = ExportSchema.get(previous_export_id) if previous_export_id else None
    database = get_db()
    config = ExportConfiguration(database, schema_index, previous_export, filter)

    # handle empty case
    if not config.potentially_relevant_ids:
        return None

    # get and checkpoint the latest schema
    updated_schema = get_schema_new(config)
    export_schema_checkpoint = ExportSchema(seq=config.current_seq, schema=updated_schema, index=config.schema_index)
    export_schema_checkpoint.save()

    # transform docs onto output and save
    writer = get_writer(format)

    # open the doc and the headers
    formatted_headers = get_headers(updated_schema, separator=separator)
    writer.open(formatted_headers, file)

    for doc in config.get_docs():
        writer.write(
            format_tables(create_intermediate_tables(doc, updated_schema), include_headers=False, separator=separator)
        )
    writer.close()
    return export_schema_checkpoint
开发者ID:wbnigeria,项目名称:couchexport,代码行数:42,代码来源:export.py

示例7: testGetLast

# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import save [as 别名]
    def testGetLast(self):
        indices = ["a string", ["a", "list"]]
        save_args = get_safe_write_kwargs()

        for index in indices:
            self.assertEqual(None, ExportSchema.last(index))
            dt = datetime.utcnow()
            schema1 = ExportSchema(index=index, timestamp=dt)
            schema1.save(**save_args)
            self.assertEqual(schema1._id, ExportSchema.last(index)._id)
            schema2 = ExportSchema(index=index, timestamp=dt + timedelta(seconds=1))
            schema2.save(**save_args)
            self.assertEqual(schema2._id, ExportSchema.last(index)._id)
            schema3 = ExportSchema(index=index, timestamp=dt - timedelta(seconds=1))
            schema3.save(**save_args)
            self.assertEqual(schema2._id, ExportSchema.last(index)._id)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:18,代码来源:test_schema.py

示例8: testGetLast

# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import save [as 别名]
    def testGetLast(self):
        indices = ["a string", ["a", "list"]]
        save_args = get_safe_write_kwargs()

        for index in indices:
            self.assertEqual(None, ExportSchema.last(index))
            # by design, if something has a timestamp it always wins out, even
            # if something has a higher seq

            dt = datetime.utcnow()
            schema1 = ExportSchema(seq="2", index=index, timestamp=dt)
            schema1.save(**save_args)
            self.assertEqual(schema1._id, ExportSchema.last(index)._id)
            schema2 = ExportSchema(seq="1", index=index, timestamp=dt + timedelta(seconds=1))
            schema2.save(**save_args)
            self.assertEqual(schema2._id, ExportSchema.last(index)._id)
            schema3 = ExportSchema(seq="3", index=index, timestamp=dt - timedelta(seconds=1))
            schema3.save(**save_args)
            self.assertEqual(schema2._id, ExportSchema.last(index)._id)
开发者ID:kennknowles,项目名称:couchexport,代码行数:21,代码来源:test_schema.py

示例9: test_get_last

# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import save [as 别名]
    def test_get_last(self):
        indices = ["a string", ["a", "list"]]
        save_args = get_safe_write_kwargs()

        for index in indices:
            self.addCleanup(
                lambda idx: [cp.delete() for cp in ExportSchema.get_all_checkpoints(idx)],
                index
            )

        for index in indices:
            self.assertEqual(None, ExportSchema.last(index))
            dt = datetime.utcnow()
            schema1 = ExportSchema(index=index, timestamp=dt)
            schema1.save(**save_args)
            self.assert_docs_equal(schema1, ExportSchema.last(index))
            schema2 = ExportSchema(index=index, timestamp=dt + timedelta(seconds=1))
            schema2.save(**save_args)
            self.assert_docs_equal(schema2, ExportSchema.last(index))
            schema3 = ExportSchema(index=index, timestamp=dt - timedelta(seconds=1))
            schema3.save(**save_args)
            # still schema2 (which has a later date than schema3)
            self.assert_docs_equal(schema2, ExportSchema.last(index))
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:25,代码来源:test_schema.py

示例10: create_basic_form_checkpoint

# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import save [as 别名]
def create_basic_form_checkpoint(index):
    checkpoint = ExportSchema(seq="0", schema=BASIC_FORM_SCHEMA, timestamp=datetime.utcnow(), index=index)
    checkpoint.save()
    return checkpoint
开发者ID:dszafranek,项目名称:commcare-hq,代码行数:6,代码来源:views.py


注:本文中的couchexport.models.ExportSchema.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。