cubicweb.dataimport¶
Package containing various utilities to import data into cubicweb.
Utilities¶
-
cubicweb.dataimport.ucsvreader_pb(stream_or_path, encoding='utf-8', delimiter=', ', quotechar='"', skipfirst=False, withpb=True, skip_empty=True)[source]¶ same as
ucsvreader()but a progress bar is displayed as we iter on rows
-
cubicweb.dataimport.ucsvreader(stream, encoding='utf-8', delimiter=', ', quotechar='"', skipfirst=False, ignore_errors=False, skip_empty=True)[source]¶ A csv reader that accepts files with any encoding and outputs unicode strings
if skip_empty (the default), lines without any values specified (only separators) will be skipped. This is useful for Excel exports which may be full of such lines.
Object Stores¶
-
class
cubicweb.dataimport.RQLObjectStore(cnx)[source]¶ Bases:
cubicweb.dataimport.stores.NullStoreStore that works by making RQL queries, hence with all the cubicweb’s machinery activated.
-
prepare_insert_entity(*args, **kwargs)[source]¶ Given an entity type, attributes and inlined relations, return the inserted entity’s eid.
-
prepare_insert_relation(eid_from, rtype, eid_to, **kwargs)[source]¶ Insert into the database a relation
rtypebetween entities with eidseid_fromandeid_to.
-
-
class
cubicweb.dataimport.NoHookRQLObjectStore(cnx, metagen=None)[source]¶ Bases:
cubicweb.dataimport.stores.RQLObjectStoreStore that works by accessing low-level CubicWeb’s source API, with all hooks deactivated. It may be given a metadata generator object to handle metadata which are usually handled by hooks.
Arguments: - cnx, a connection to the repository - metagen, optional
MetadataGeneratorinstance