Skip to content

Add command line option to connect to Redis with unix socket #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
8 changes: 6 additions & 2 deletions redisgraph_bulk_loader/bulk_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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.")

Expand All @@ -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
Expand Down