Command line tool to convert MySql database into Realm object database
the plans are to get support for
mssql
as for other sql adapters, so any contribution is very welcome
Install using yarn
:
yarn global add sql2realm
Or via npm
:
npm install -g sql2realm
Usage: sql2realm [config file]
Options:
--help Show help [boolean]
--version Show version number [boolean]
-s, --skip skip some tables [array] [default: []]
-c, --chunk chunk size [default: 10000]
let say we have Mysql server up and running and have a database named mock
with a table named mock_data
(see the dump)
and this is the config file config.json
{
"mysql": {
"host": "127.0.0.1",
"user": "test",
"password": "test",
"database": "mock"
},
"realm": {
"database": "./db.realm"
},
"tables": {
"mock_data": {
"schema": {
"name": "Users",
"primaryKey": "id",
"properties": {
"id": "int",
"first_name": "string",
"last_name": "string",
"email": "string",
"gender": "string",
"ip_address": "string"
}
},
}
}
}
lets discuss config file sections one by one:
"mysql": {...}
this is regular mysql/mariadb connection options
"realm": {...}
for realm there is only one option:
database
- path to database that will be created
this are the tables from sql to be converted into Realm
"tables": {
"mock_data": {
"schema": {
mock_data
- is the real name of table in Mysqlschema
- is the Realm DB Schema. It should be designed according to Realm principles.
MIT