Skip to content

Commit cdfe6fa

Browse files
authored
Added option to connect with unix socket (#49)
Added the option to use a unix socket path instead of a (host, port) for connecting to the Redis instance.
1 parent acf0d55 commit cdfe6fa

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ python3 redisgraph_bulk_loader/bulk_insert.py GRAPHNAME [OPTIONS]
4242
| -h | --host TEXT | Redis server host (default: 127.0.0.1) |
4343
| -p | --port INTEGER | Redis server port (default: 6379) |
4444
| -a | --password TEXT | Redis server password (default: none) |
45+
| -u | --unix-socket-path TEXT | Redis unix socket path (default: none) |
4546
| -n | --nodes TEXT | Path to Node CSV file with the filename as the Node Label |
4647
| -N | --nodes-with-label TEXT | Node Label followed by path to Node CSV file |
4748
| -r | --relations TEXT | Path to Relationship CSV file with the filename as the Relationship Type |

redisgraph_bulk_loader/bulk_insert.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def process_entities(entities):
4747
@click.option('--host', '-h', default='127.0.0.1', help='Redis server host')
4848
@click.option('--port', '-p', default=6379, help='Redis server port')
4949
@click.option('--password', '-a', default=None, help='Redis server password')
50+
@click.option('--unix-socket-path', '-u', default=None, help='Redis server unix socket path')
5051
# CSV file paths
5152
@click.option('--nodes', '-n', multiple=True, help='Path to node csv file')
5253
@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):
6465
@click.option('--max-token-size', '-t', default=500, help='max size of each token in megabytes (default 500, max 512)')
6566
@click.option('--index', '-i', multiple=True, help='Label:Propery on which to create an index')
6667
@click.option('--full-text-index', '-f', multiple=True, help='Label:Propery on which to create an full text search index')
67-
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):
68+
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):
6869
if sys.version_info[0] < 3:
6970
raise Exception("Python 3 is required for the RedisGraph bulk loader.")
7071

@@ -81,7 +82,10 @@ def bulk_insert(graph, host, port, password, nodes, nodes_with_label, relations,
8182

8283
# Attempt to connect to Redis server
8384
try:
84-
client = redis.StrictRedis(host=host, port=port, password=password)
85+
if unix_socket_path is not None:
86+
client = redis.StrictRedis(unix_socket_path=unix_socket_path, password=password)
87+
else:
88+
client = redis.StrictRedis(host=host, port=port, password=password)
8589
except redis.exceptions.ConnectionError as e:
8690
print("Could not connect to Redis server.")
8791
raise e

0 commit comments

Comments
 (0)