Skip to content

Command line tool to convert MySql database into Realm object database

Notifications You must be signed in to change notification settings

gkoychev/sql2realm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sql2realm

Command line tool to convert MySql database into Realm object database

Build Status

the plans are to get support for mssql as for other sql adapters, so any contribution is very welcome

Getting Started

Install using yarn:

yarn global add sql2realm

Or via npm:

npm install -g sql2realm

Usage


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]

Example

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 connection options

"mysql": {...}

this is regular mysql/mariadb connection options

realm db options

"realm": {...}

for realm there is only one option:

  • database - path to database that will be created

Tables

this are the tables from sql to be converted into Realm

  "tables": {
    "mock_data": {
      "schema": {
  • mock_data - is the real name of table in Mysql
  • schema - is the Realm DB Schema. It should be designed according to Realm principles.

License

MIT

About

Command line tool to convert MySql database into Realm object database

Resources

Stars

Watchers

Forks

Packages

No packages published