Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBM DB2 migration #868

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 160 additions & 25 deletions pages/advanced-algorithms/available-algorithms/migrate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,65 @@ A module that contains procedures describing graphs on a meta-level.

## Procedures

### `db2()`

With the `migrate.db2()` procedure you can access IBM DB2 and migrate your data
to Memgraph. The result table is converted into a stream, and the 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/at least an empty map/a map, either empty or populated with configuration key/value pairs

JSON file will overwrite any values in `config` file.

{<h4> Input: </h4>}

* `table_or_sql: str` ➡ Table name or an SQL query. When the table name is specified, the module
will migrate all the rows from the table. In the case that a SQL query is provided, the module
will migrate the rows returned from the queries.
* `config: mgp.Map` ➡ Connection configuration parameters (as in `ibm_db.connect`).
* `config_path` ➡ Path to the JSON file containing configuration parameters (as in `ibm_db.connect`).
* `params: mgp.Nullable[mgp.Any] (default=None)` ➡ Optionally, queries can be parameterized. In that case, `params` provides parameter values.

{<h4> Output: </h4>}

* `row: mgp.Map`: The result table as a stream of rows.

{<h4> Usage: </h4>}

To get all data from database in form of map, use the following query:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/get/inspect


```cypher
CALL migrate.db2('example_table', {user:'memgraph',
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN row;
```

In the case you want to migrate specific results from a SQL query, it is enough to modify the
first argument of the query module call:

```cypher
CALL migrate.db2('SELECT * FROM example_table', {user:'memgraph',
hal-eisen-MG marked this conversation as resolved.
Show resolved Hide resolved
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN count(row);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why count(row) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified the examples to be without counts and with arbitrary cypher functionalities.

```

### `mysql()`

With the `migrate.mysql()` procedure you can access MySQL and execute queries.
With the `migrate.mysql()` procedure you can access MySQL and migrate your data to Memgraph.
The result table is converted into a stream, and the 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
an empty map. If `config_path` is passed, every key-value pair from JSON file
will overwrite any values in `config` file.

{<h4> Input: </h4>}

* `table_or_sql: str` ➡ Table name or an SQL query.
* `table_or_sql: str` ➡ Table name or an SQL query. When the table name is specified, the module
will migrate all the rows from the table. In the case that a SQL query is provided, the module
will migrate the rows returned from the queries.
* `config: mgp.Map` ➡ Connection configuration parameters (as in `mysql.connector.connect`).
* `config_path` ➡ Path to a JSON file containing configuration parameters (as in `mysql.connector.connect`).
* `params: mgp.Nullable[mgp.Any] (default=None)` ➡ Optionally, queries can be parameterized. In that case, `params` provides parameter values.
Expand All @@ -59,51 +107,80 @@ YIELD row
RETURN count(row);
```

### `sql_server()`
In the case you want to migrate specific results from a SQL query, it is enough to modify the
first argument of the query module call:

With the `migrate.sql_server()` procedure you can access SQL Server and execute
queries. The result table is converted into a stream, and the 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.
```cypher
CALL migrate.mysql('SELECT * FROM example_table', {user:'memgraph',
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN count(row);
```

### `oracle_db()`

With the `migrate.oracle_db` you can access Oracle DB and migrate your data to Memgraph.
The result table is converted into a stream, and the 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.

{<h4> Input: </h4>}

* `table_or_sql: str` ➡ Table name or an SQL query.
* `config: mgp.Map` ➡ Connection configuration parameters (as in `pyodbc.connect`).
* `config_path` ➡ Path to the JSON file containing configuration parameters (as in `pyodbc.connect`).
* `params: mgp.Nullable[mgp.Any] (default=None)` ➡ Optionally, queries can be parameterized. In that case, `params` provides parameter values.
* `table_or_sql: str` ➡ Table name or an SQL query. When the table name is specified, the module
will migrate all the rows from the table. In the case that a SQL query is provided, the module
will migrate the rows returned from the queries.
* `config: 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.

{<h4> Output: </h4>}

* `row: mgp.Map`: The result table as a stream of rows.

{<h4> Usage: </h4>}

To get all data from database in form of map, use the following query:
To get the first 5000 rows from a database, use the following query:

```cypher
CALL migrate.sql_server('example_table', {user:'memgraph',
CALL migrate.oracle_db('example_table', {user:'memgraph',
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN row;
RETURN row
LIMIT 5000;
```

### `oracle_db()`
In the case you want to migrate specific results from a SQL query, it is enough to modify the
first argument of the query module call:

With the `migrate.oracle_db` you can access Oracle DB and execute queries. The
result table is converted into a stream, and the returned rows can be used to
```cypher
CALL migrate.oracle_db('SELECT * FROM example_table', {user:'memgraph',
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN count(row);
```

### `postgresql()`

With the `migrate.postgresql` you can access PostgreSQL and migrate your data to Memgraph.
The result table is converted into a stream, and the 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
empty map. If `config_path` is passed, every key-value pair from JSON file will
overwrite any values in `config` file.

{<h4> Input: </h4>}

* `table_or_sql: str` ➡ Table name or an SQL query.
* `config: mgp.Map` ➡ Connection configuration parameters (as in `oracledb.connect`).
* `config_path` ➡ Path to the JSON file containing configuration parameters (as in `oracledb.connect`).
* `table_or_sql: str` ➡ Table name or an SQL query. When the table name is specified, the module
will migrate all the rows from the table. In the case that a SQL query is provided, the module
will migrate the rows returned from the queries.
* `config: mgp.Map` ➡ Connection configuration parameters (as in `psycopg2.connect`).
* `config_path` ➡ Path to the JSON file containing configuration parameters (as in `psycopg2.connect`).
* `params: mgp.Nullable[mgp.Any] (default=None)` ➡ Optionally, queries may be parameterized. In that case, `params` provides parameter values.

{<h4> Output: </h4>}
Expand All @@ -115,11 +192,69 @@ overwrite any values in `config` file.
To get the first 5000 rows from a database, use the following query:

```cypher
CALL migrate.oracle_db('example_table', {user:'memgraph',
CALL migrate.postgresql('example_table', {user:'memgraph',
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN row
LIMIT 5000;
```
```

In the case you want to migrate specific results from a SQL query, it is enough to modify the
first argument of the query module call:

```cypher
CALL migrate.postgresql('SELECT * FROM example_table', {user:'memgraph',
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN count(row);
```

### `sql_server()`

With the `migrate.sql_server()` procedure you can access SQL Server and migrate your data
to Memgraph. The result table is converted into a stream, and the 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.

{<h4> Input: </h4>}

* `table_or_sql: str` ➡ Table name or an SQL query. When the table name is specified, the module
will migrate all the rows from the table. In the case that a SQL query is provided, the module
will migrate the rows returned from the queries.
* `config: mgp.Map` ➡ Connection configuration parameters (as in `pyodbc.connect`).
* `config_path` ➡ Path to the JSON file containing configuration parameters (as in `pyodbc.connect`).
* `params: mgp.Nullable[mgp.Any] (default=None)` ➡ Optionally, queries can be parameterized. In that case, `params` provides parameter values.

{<h4> Output: </h4>}

* `row: mgp.Map`: The result table as a stream of rows.

{<h4> Usage: </h4>}

To get all data from database in form of map, use the following query:

```cypher
CALL migrate.sql_server('example_table', {user:'memgraph',
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN row;
```

In the case you want to migrate specific results from a SQL query, it is enough to modify the
first argument of the query module call:

```cypher
CALL migrate.sql_server('SELECT * FROM example_table', {user:'memgraph',
password:'password',
host:'localhost',
database:'demo_db'} )
YIELD row
RETURN count(row);
```