Migrates Oracle dbs to PostgreSQL, MySQL and SQLite
Project description
CBL Migrator
Small SQLAlchemy based library that migrates Oracle DBs to MySQL, PostgreSQL and SQLite. Used in ChEMBL dumps generation process.
to use it, as a Python library:
from cbl_migrator import DbMigrator
origin = 'oracle://{user}:{pass}@{host}:{port}/?service_name={service_name}&encoding=utf8'
#dest = 'mysql://{user}:{pass}@{host}:{port}/{dbname}?use_unicode=1&charset=utf8'
dest = 'postgresql://{user}:{pass}@{host}:{port}/{dbname}?client_encoding=utf8'
migrator = DbMigrator(origin, dest, ['excluded_table1', 'excluded_table2'], n_workers=4)
migrator.migrate()
directly from the command line:
cbl-migrator "oracle://{user}:{pass}@{host}:{port}/?service_name={service_name}&encoding=utf8" "postgresql://{user}:{pass}@{host}:{port}/{dbname}?client_encoding=utf8" --n_workers 8
What it does (in order of events)
- Copies tables from origin to dest using the closest data type for each field. No constraints except PKs are initially copied across.
- Table contents are migrated from origin to dest tables. In parallel.
- If the data migration is succesful it will first generate the constraints and then the indexes. Any index in a field with a previously created UK will be skipped (UKs are implemented as unique indexes).
- It logs every time it was not possible to migrate an object, e.g.,
(psycopg2.OperationalError) index row size 2856 exceeds maximum 2712 for index.
What it does not do
- It won't migrate any table without a PK. May hang with a table without PK and containing an UK field referenced as FK in another table.
- It does not try to migrate server default values.
- It does not set autoincremental fields.
- It does not try to migrate triggers nor procedures.
SQLite
SQLite can not:
- concurrently write
- alter table ADD CONSTRAINT
So only one core is used when migrating to it. All constraints are generated at the time of generating the destination tables and it sequentially inserts rows in tables in correct FKs order.
MySQL
CLOBs are migrated to LONGTEXT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cbl_migrator-0.3.6.tar.gz
(9.7 kB
view details)
Built Distribution
File details
Details for the file cbl_migrator-0.3.6.tar.gz
.
File metadata
- Download URL: cbl_migrator-0.3.6.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cedc6e4f5d73905e7aec97e471789aee4819be34a5bdc7a594af6275d211299 |
|
MD5 | 519d8a445c0863e44ba47c3df02e37fe |
|
BLAKE2b-256 | 7d757a644ac4c76c571330f01cec104fce5e58eeffde83cc224202d23bb8c992 |
File details
Details for the file cbl_migrator-0.3.6-py3-none-any.whl
.
File metadata
- Download URL: cbl_migrator-0.3.6-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05a169a9c894349d09cc361e9d898996e28fd1443e8aff6029863a99d922fd66 |
|
MD5 | 6d8d31eb8d5a9aa3d6768a418abb3e52 |
|
BLAKE2b-256 | 196f0d103c7540ab24c5a9fa73a24c6dd5414b89e06f8665aa6565c37520a301 |