diff --git a/README.md b/README.md index 2005f19..721c6e8 100644 --- a/README.md +++ b/README.md @@ -39,13 +39,7 @@ python3 redisgraph_bulk_loader/bulk_insert.py GRAPHNAME [OPTIONS] | Flags | Extended flags | Parameter | |:-----:|----------------------------|:----------------------------------------------------------------------------------------------------:| -| -h | --host TEXT | Redis server host (default: 127.0.0.1) | -| -p | --port INTEGER | Redis server port (default: 6379) | -| -a | --password TEXT | Redis server password (default: none) | -| -u | --unix-socket-path TEXT | Redis unix socket path (default: none) | -| -k | --ssl-keyfile TEXT | Path to SSL keyfile (default: none) | -| -l | --ssl-certfile TEXT | Path to SSL certfile (default: none) | -| -m | --ssl-ca-certs TEXT | Path to SSL CA certs (default: none) | +| -u | --redis-url TEXT | Redis url (default: redis://127.0.0.1:6379) | | -n | --nodes TEXT | Path to Node CSV file with the filename as the Node Label | | -N | --nodes-with-label TEXT | Node Label followed by path to Node CSV file | | -r | --relations TEXT | Path to Relationship CSV file with the filename as the Relationship Type | diff --git a/redisgraph_bulk_loader/bulk_insert.py b/redisgraph_bulk_loader/bulk_insert.py index bcd2949..8935710 100644 --- a/redisgraph_bulk_loader/bulk_insert.py +++ b/redisgraph_bulk_loader/bulk_insert.py @@ -1,4 +1,3 @@ -import ssl import sys from timeit import default_timer as timer @@ -51,17 +50,9 @@ def process_entities(entities): @click.command() @click.argument("graph") # Redis server connection settings -@click.option("--host", "-h", default="127.0.0.1", help="Redis server host") -@click.option("--port", "-p", default=6379, help="Redis server port") -@click.option("--password", "-a", default=None, help="Redis server password") -@click.option("--user", "-w", default=None, help="Username for Redis ACL") @click.option( - "--unix-socket-path", "-u", default=None, help="Redis server unix socket path" + "--redis-url", "-u", default="redis://127.0.0.1:6379", help="Redis connection url" ) -@click.option("--ssl-keyfile", "-k", default=None, help="SSL keyfile") -@click.option("--ssl-certfile", "-l", default=None, help="SSL certfile") -@click.option("--ssl-ca-certs", "-m", default=None, help="SSL CA certs") -# CSV file paths @click.option("--nodes", "-n", multiple=True, help="Path to node csv file") @click.option( "--nodes-with-label", @@ -151,14 +142,7 @@ def process_entities(entities): ) def bulk_insert( graph, - host, - port, - password, - user, - unix_socket_path, - ssl_keyfile, - ssl_certfile, - ssl_ca_certs, + redis_url, nodes, nodes_with_label, relations, @@ -202,25 +186,11 @@ def bulk_insert( escapechar, ) - kwargs = {"host": host, "port": port, "username": user, "password": password} - - if unix_socket_path is not None: - kwargs.update({"unix_socket_path": unix_socket_path}) - - if ssl_keyfile or ssl_certfile or ssl_ca_certs: - kwargs.update( - { - "ssl": True, - "ssl_keyfile": ssl_keyfile, - "ssl_certfile": ssl_certfile, - "ssl_cert_reqs": ssl.CERT_REQUIRED, - "ssl_ca_certs": ssl_ca_certs, - } - ) + client = redis.from_url(redis_url) # Attempt to connect to Redis server try: - client = redis.Redis(**kwargs) + client.ping() except redis.exceptions.ConnectionError as e: print("Could not connect to Redis server.") raise e diff --git a/redisgraph_bulk_loader/bulk_update.py b/redisgraph_bulk_loader/bulk_update.py index 487da14..1144c77 100644 --- a/redisgraph_bulk_loader/bulk_update.py +++ b/redisgraph_bulk_loader/bulk_update.py @@ -129,12 +129,8 @@ def process_update_csv(self): @click.command() @click.argument("graph") # Redis server connection settings -@click.option("--host", "-h", default="127.0.0.1", help="Redis server host") -@click.option("--port", "-p", default=6379, help="Redis server port") -@click.option("--password", "-a", default=None, help="Redis server password") -@click.option("--user", "-w", default=None, help="Username for Redis ACL") @click.option( - "--unix-socket-path", "-u", default=None, help="Redis server unix socket path" + "--redis-url", "-u", default="redis://127.0.0.1:6379", help="Redis connection url" ) # Cypher query options @click.option("--query", "-q", help="Query to run on server") @@ -165,11 +161,7 @@ def process_update_csv(self): ) def bulk_update( graph, - host, - port, - password, - user, - unix_socket_path, + redis_url, query, variable_name, csv, @@ -183,22 +175,9 @@ def bulk_update( start_time = timer() # Attempt to connect to Redis server + client = redis.from_url(redis_url, decode_responses=True) try: - if unix_socket_path is not None: - client = redis.StrictRedis( - unix_socket_path=unix_socket_path, - username=user, - password=password, - decode_responses=True, - ) - else: - client = redis.StrictRedis( - host=host, - port=port, - username=user, - password=password, - decode_responses=True, - ) + client.ping() except redis.exceptions.ConnectionError as e: print("Could not connect to Redis server.") raise e