diff --git a/README.md b/README.md index 84ffb29..3996247 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ python3 redisgraph_bulk_loader/bulk_insert.py GRAPHNAME [OPTIONS] | -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) | | -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 33215d7..bd312b3 100644 --- a/redisgraph_bulk_loader/bulk_insert.py +++ b/redisgraph_bulk_loader/bulk_insert.py @@ -47,6 +47,7 @@ def process_entities(entities): @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('--unix-socket-path', '-u', default=None, help='Redis server unix socket path') # CSV file paths @click.option('--nodes', '-n', multiple=True, help='Path to node csv file') @click.option('--nodes-with-label', '-N', nargs=2, multiple=True, help='Label string followed by path to node csv file') @@ -64,7 +65,7 @@ def process_entities(entities): @click.option('--max-token-size', '-t', default=500, help='max size of each token in megabytes (default 500, max 512)') @click.option('--index', '-i', multiple=True, help='Label:Propery on which to create an index') @click.option('--full-text-index', '-f', multiple=True, help='Label:Propery on which to create an full text search index') -def bulk_insert(graph, host, port, password, nodes, nodes_with_label, relations, relations_with_type, separator, enforce_schema, skip_invalid_nodes, skip_invalid_edges, quote, max_token_count, max_buffer_size, max_token_size, index, full_text_index): +def bulk_insert(graph, host, port, password, unix_socket_path, nodes, nodes_with_label, relations, relations_with_type, separator, enforce_schema, skip_invalid_nodes, skip_invalid_edges, quote, max_token_count, max_buffer_size, max_token_size, index, full_text_index): if sys.version_info[0] < 3: raise Exception("Python 3 is required for the RedisGraph bulk loader.") @@ -81,7 +82,10 @@ def bulk_insert(graph, host, port, password, nodes, nodes_with_label, relations, # Attempt to connect to Redis server try: - client = redis.StrictRedis(host=host, port=port, password=password) + if unix_socket_path is not None: + client = redis.StrictRedis(unix_socket_path=unix_socket_path, password=password) + else: + client = redis.StrictRedis(host=host, port=port, password=password) except redis.exceptions.ConnectionError as e: print("Could not connect to Redis server.") raise e