From e8130d82763cbacd12a8cc40234824fcd2b9c267 Mon Sep 17 00:00:00 2001 From: A_Bassiouny Date: Tue, 2 Jul 2024 01:03:35 +0200 Subject: [PATCH] made some defaults to make command line interface easier --- README.md | 54 +++++++++++++------------------- pyproject.toml | 2 +- src/neems_to_sql/neems_to_sql.py | 8 ++--- 3 files changed, 27 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 66b6cc4..c68f651 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,8 @@ You need to have both [MongoDB](https://www.mongodb.com/docs/manual/tutorial/ins ## Installation -Clone the repository: ``` -git clone git@github.com:AbdelrhmanBassiouny/neem_to_sql.git -``` - -Go to package root directory, then do: -``` -pip install -r requirements.txt +pip install neem_to_sql ``` ## Recommendations @@ -48,16 +42,16 @@ Make sure that you have MonoDB server running: sudo systemctl start mongod.service ``` -The usage is straight forward, if you have your new neems on a MongoDB, and you have the credentials for access to the MongoDB and the MariaDB, then you are good to go. The only file you need to run is "migrate_neems_to_sql.py", for example the following command uses the sql database (always required), sql uri and the mongo uri instead of providing username, password, and hostname, arguments, this is for providing more flexibility: +The usage is straight forward, if you have your new neems on a MongoDB, and you have the credentials for access to the MongoDB and the MariaDB, then you are good to go. The following command uses the sql database, sql uri and the mongo uri instead of providing username, password, and hostname, arguments, this is for providing more flexibility: ``` -python migrate_neems_to_sql.py -sbt -ais --sql_uri "mysql+pymysql://newuser:password@localhost/test?charset=utf8mb4" --mongo_uri "mongodb://newuser:password@localhost:27017/neems" +neems_to_sql --sql_uri "mysql+pymysql://newuser:password@localhost/test?charset=utf8mb4" --mongo_uri "mongodb://newuser:password@localhost:27017/neems" ``` Another way is using the specific arguments: ``` -python migrate_neems_to_sql.py -sbt -ais -su "sql_username" -sp "sql_password" -sh "localhost" -sd "my_sql_database" -mu "mongo_username" -mp "mongo_password" -md "neems" -mh "localhost" -mpt 27017 +neems_to_sql -su "sql_username" -sp "sql_password" -sh "localhost" -sd "my_sql_database" -mu "mongo_username" -mp "mongo_password" -md "neems" -mh "localhost" -mpt 27017 ``` The above commands assumes that you have an sql database called "my_sql_database" and a mongo database called "neems". @@ -71,30 +65,26 @@ If all is good you should see something like this: For all usages of the command line see the command line arguments documentation below: ``` -usage: migrate_neems_to_sql.py [-h] [--drop_neems] [--drop_tables] - [--skip_bad_triples] [--allow_increasing_sz] - [--allow_text_indexing] - [--max_null_percentage MAX_NULL_PERCENTAGE] - [--batch_size BATCH_SIZE] - [--number_of_batches NUMBER_OF_BATCHES] - [--start_batch START_BATCH] - [--dump_data_stats] - [--sql_username SQL_USERNAME] - [--sql_password SQL_PASSWORD] - [--sql_database SQL_DATABASE] - [--sql_host SQL_HOST] [--sql_uri SQL_URI] - [--mongo_username MONGO_USERNAME] - [--mongo_password MONGO_PASSWORD] - [--mongo_database MONGO_DATABASE] - [--mongo_host MONGO_HOST] - [--mongo_port MONGO_PORT] - [--mongo_uri MONGO_URI] - [--log_level LOG_LEVEL] - [--neem_filters_yaml NEEM_FILTERS_YAML] +usage: neems_to_sql [-h] [--drop_neems] [--drop_tables] [--skip_bad_triples] + [--allow_increasing_sz] [--allow_text_indexing] + [--max_null_percentage MAX_NULL_PERCENTAGE] + [--batch_size BATCH_SIZE] + [--number_of_batches NUMBER_OF_BATCHES] + [--start_batch START_BATCH] [--dump_data_stats] + [--sql_username SQL_USERNAME] + [--sql_password SQL_PASSWORD] + [--sql_database SQL_DATABASE] [--sql_host SQL_HOST] + [--sql_uri SQL_URI] [--mongo_username MONGO_USERNAME] + [--mongo_password MONGO_PASSWORD] + [--mongo_database MONGO_DATABASE] + [--mongo_host MONGO_HOST] [--mongo_port MONGO_PORT] + [--mongo_uri MONGO_URI] [--log_level LOG_LEVEL] + [--neem_filters_yaml NEEM_FILTERS_YAML] optional arguments: -h, --help show this help message and exit - --drop_neems, -dn Drop the neems to be recreated/updated before creating them + --drop_neems, -dn Drop the neems to be recreated/updated before + creating them --drop_tables, -dt Drop all tables first --skip_bad_triples, -sbt Skip triples that are missing one of subject, @@ -150,7 +140,7 @@ optional arguments: Default is INFO --neem_filters_yaml NEEM_FILTERS_YAML, -nfy NEEM_FILTERS_YAML YAML file containing the neem filters, Default is - ../my_neem_filters.yaml + None ``` diff --git a/pyproject.toml b/pyproject.toml index 0ce6c37..497fb52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" [project] name = "neem_to_sql" -version = "1.0.6" +version = "1.0.7" description = "Convert NEEMs database from Mongo to SQL" readme = "README.md" authors = [{ name = "Abdelrhman Bassiouny", email = "abassiou@uni-bremen.de" }] diff --git a/src/neems_to_sql/neems_to_sql.py b/src/neems_to_sql/neems_to_sql.py index 88acd9c..bb7e37c 100644 --- a/src/neems_to_sql/neems_to_sql.py +++ b/src/neems_to_sql/neems_to_sql.py @@ -1994,10 +1994,10 @@ def parse_arguments(): parser.add_argument("--drop_neems", "-dn", action="store_true", help="Drop the neems to be " "recreated/updated before creating them") parser.add_argument("--drop_tables", "-dt", action="store_true", help="Drop all tables first") - parser.add_argument("--skip_bad_triples", "-sbt", action="store_true", - help="Skip triples that are missing one of subject, predicate or object") - parser.add_argument("--allow_increasing_sz", "-ais", action="store_true", - help="Allow increasing the size of the original data type of a column") + parser.add_argument("--allow_bad_triples", "-abt", dest="skip_bad_triples", action="store_false", + help="Allow triples that are missing one of subject, predicate or object", default=True) + parser.add_argument("--disable_increasing_sz", "-dis", dest="allow_increasing_sz", action="store_false", + help="Disable increasing the size of the original data type of a column", default=True) parser.add_argument("--allow_text_indexing", "-ati", action="store_true", help="Allow indexing text type columns") parser.add_argument("--max_null_percentage", "-mnp", default=5, type=float,