-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add console script * update README
- Loading branch information
Showing
5 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import argparse | ||
from cbl_migrator import DbMigrator | ||
from multiprocessing import cpu_count | ||
import sys | ||
|
||
|
||
def run(origin, dest, n_workers, copy_schema, copy_data, copy_constraints, copy_indexes, chunk_size): | ||
migrator = DbMigrator(origin, dest, n_workers=int(n_workers)) | ||
migrator.migrate(copy_schema=copy_schema, copy_data=copy_data, | ||
copy_constraints=copy_constraints, copy_indexes=copy_indexes, chunk_size=int(chunk_size)) | ||
print('Migration finished, check cbl_migrator.log file for extra information') | ||
|
||
|
||
def main(args=None): | ||
if args is None: | ||
args = sys.argv[1:] | ||
|
||
parser = argparse.ArgumentParser( | ||
description='Migrate an Oracle database to a PosgreSQL, MySQL or SQLite server') | ||
parser.add_argument('origin', | ||
help='Origin database connection string', | ||
default=None) | ||
parser.add_argument('dest', | ||
help='Destination database connection string', | ||
default=None) | ||
|
||
parser.add_argument('--n_workers', | ||
help='Number of workers migrating tables in parallel', | ||
default=cpu_count()) | ||
|
||
parser.add_argument('--copy_schema', | ||
help='Copy database schema', | ||
default=True) | ||
|
||
parser.add_argument('--copy_data', | ||
help='Copy data', | ||
default=True) | ||
|
||
parser.add_argument('--copy_constraints', | ||
help='Copy constraints', | ||
default=True) | ||
|
||
parser.add_argument('--copy_indexes', | ||
help='Copy indexes', | ||
default=True) | ||
|
||
parser.add_argument('--chunk_size', | ||
help='Number of rows copied at the same time', | ||
default=1000) | ||
|
||
args = parser.parse_args() | ||
run(args.origin, args.dest, args.n_workers, args.copy_schema, | ||
args.copy_data, args.copy_constraints, args.copy_indexes, args.chunk_size) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters