Relational modules
The provided implementations for relational entities. They implement the abstract classes of the main interface.
SQLite
Implements the Resource
and ResourceIterator
for sqlite based on sqlite3.
SQLiteResource
- class data2neo.relational_modules.sqlite.SQLiteResource[source]
Bases:
Resource
Implementation of the sqlite Resource. Enables access to a row of a sqlite table
- __init__(data: Iterable, cols: List[str], pks: List[str], table: str) None [source]
Wraps a row of a sqlite table and is used as input data object for the converter. May hold additional supplies to pass data between factories.
- Parameters
data – Wrapped row of a sqlite table.
cols – List of column names.
pks – List of primary keys.
table – Name of table that this row is an entity of.
- property type: str
Returns the type of the resource. Is used to select correct factory
- property pks: Dict[str, Any]
Returns the primary keys of the resource
- property cols: List[str]
Returns the columns of the resource
- clear_supplies() None
Clears the supplies
- property supplies: Dict
Returns access to supplies from past factories. Is used to pass data between factories. This should not be customised.
SQLiteIterator
- class data2neo.relational_modules.sqlite.SQLiteIterator[source]
Bases:
ResourceIterator
Implementation of the sqlite ResourceIterator. Enables iteration over a sqlite database.
- __init__(database: Connection, filter: List[str] = None, primary_keys: Dict[str, List[str]] = None, mix_tables: bool = True, buffer_size: int = 5000, lock: Lock = None) None [source]
Initializes the iterator. Opens a connection to the database and saves the tables that should be iterated over.
- Parameters
database – Sqlite database connection to iterate over.
filter – List of tables to iterate over. If None all tables in database are used. Defaults to None.
primary_keys – Dict of primary keys for each table. If None the primary keys are determined automatically. Defaults to None.
mix_tables – If True, the iterator will mix the tables. If False, the iterator will iterate over all tables in order. Defaults to True.
buffer_size – Size of the buffer for each table. Defaults to 5000.
lock – Lock object to synchronize the access to the sqlite database. Defaults to None.
- Raises
Exception – If no primary key is found for a table.
Pandas
Implements the Resource
and ResourceIterator
for pandas.
PandasSeriesResource
- class data2neo.relational_modules.pandas.PandasSeriesResource[source]
Bases:
Resource
Implementation of the pandas Resource. Enables access to an pandas series
- __init__(series: Series, type: str) None [source]
Wraps a pandas series and is used as input data object for the converter. May hold additional supplies to pass data between factories.
- Parameters
series – Wrapped pandas series.
type – Name of type that this series is an entity of.
- property type: str
Returns the type of the resource. Is used to select correct factory
- property series: Dict
Gets the wrapped pandas series
- clear_supplies() None
Clears the supplies
- property supplies: Dict
Returns access to supplies from past factories. Is used to pass data between factories. This should not be customised.
PandasDataFrameIterator
- class data2neo.relational_modules.pandas.PandasDataFrameIterator[source]
Bases:
ResourceIterator
Implements a Iterator that works based on a list of pandas Entities.