migrate
A module that contains procedures describing graphs on a meta-level.
Trait | Value |
---|---|
Module type | util |
Implementation | Python |
Parallelism | sequential |
Procedures
mysql(table_or_sql, config, config_path, params)
With migrate.mysql
you can access MySQL and execute queries. The result table is converted into a stream,
and returned rows can be used to create graph structures. The value of the config
parameter must be at least an empty map. If config_path
is passed, every key,value pair from JSON file will overwrite any values in config
file.
Input:
table_or_sql: str
➡ Table name or an SQL queryconfig: mgp.Map
➡ Connection configuration parameters (as inmysql.connector.connect
)config_path
➡ Path to a JSON file containing configuration parameters (as inmysql.connector.connect
)params: mgp.Nullable[mgp.Any] (default=None)
➡ Optionally, queries can be parameterized. In that case,params
provides parameter values
Output:
row: mgp.Map
: The result table as a stream of rows
Usage:
Get count of rows:
CALL migrate.mysql('example_table', {user:'memgraph',
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN count(row);
sql_server(table_or_sql, config, config_path, params)
With migrate.sql_server
you can access SQL Server and execute queries. The result table is converted into a stream, and returned rows can be used to create graph structures. The value of the config
parameter must be at least an empty map. If config_path
is passed, every key,value pair from JSON file will overwrite any values in config
file.
Input:
table_or_sql: str
➡ Table name or an SQL queryconfig: mgp.Map
➡ Connection configuration parameters (as inpyodbc.connect
)config_path
➡ Path to the JSON file containing configuration parameters (as inpyodbc.connect
)params: mgp.Nullable[mgp.Any] (default=None)
➡ Optionally, queries can be parameterized. In that case,params
provides parameter values
Output:
row: mgp.Map
: The result table as a stream of rows
Usage:
Get all data from database in form of map:
CALL migrate.sql_server('example_table', {user:'memgraph',
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN row;
oracle_db(table_or_sql, config, config_path, params)
With migrate.oracle_db
you can access Oracle DB and execute queries. The result table is converted into a stream, and returned rows can be used to create graph structures. The value of the config
parameter must be at least an empty map. If config_path
is passed, every key,value pair from JSON file will overwrite any values in config
file.
Input:
table_or_sql: str
➡ Table name or an SQL queryconfig: mgp.Map
➡ Connection configuration parameters (as in oracledb.connect),config_path
➡ Path to the JSON file containing configuration parameters (as in oracledb.connect)params: mgp.Nullable[mgp.Any] (default=None)
➡ Optionally, queries may be parameterized. In that case,params
provides parameter values
Output:
row: mgp.Map
: The result table as a stream of rows
Usage:
Get the first 5000 rows from a database:
CALL migrate.oracle_db('example_table', {user:'memgraph',
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN row
LIMIT 5000;