Skip to content

Commit 3819b2d

Browse files
Add command-line argument to set ACL user (#58)
1 parent 9046579 commit 3819b2d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

redisgraph_bulk_loader/bulk_insert.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def process_entities(entities):
5050
@click.option('--host', '-h', default='127.0.0.1', help='Redis server host')
5151
@click.option('--port', '-p', default=6379, help='Redis server port')
5252
@click.option('--password', '-a', default=None, help='Redis server password')
53+
@click.option('--user', '-w', default=None, help='Username for Redis ACL')
5354
@click.option('--unix-socket-path', '-u', default=None, help='Redis server unix socket path')
5455
# CSV file paths
5556
@click.option('--nodes', '-n', multiple=True, help='Path to node csv file')
@@ -69,7 +70,7 @@ def process_entities(entities):
6970
@click.option('--max-token-size', '-t', default=500, help='max size of each token in megabytes (default 500, max 512)')
7071
@click.option('--index', '-i', multiple=True, help='Label:Propery on which to create an index')
7172
@click.option('--full-text-index', '-f', multiple=True, help='Label:Propery on which to create an full text search index')
72-
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, escapechar, quote, max_token_count, max_buffer_size, max_token_size, index, full_text_index):
73+
def bulk_insert(graph, host, port, password, user, unix_socket_path, nodes, nodes_with_label, relations, relations_with_type, separator, enforce_schema, skip_invalid_nodes, skip_invalid_edges, escapechar, quote, max_token_count, max_buffer_size, max_token_size, index, full_text_index):
7374
if sys.version_info[0] < 3:
7475
raise Exception("Python 3 is required for the RedisGraph bulk loader.")
7576

@@ -87,9 +88,9 @@ def bulk_insert(graph, host, port, password, unix_socket_path, nodes, nodes_with
8788
# Attempt to connect to Redis server
8889
try:
8990
if unix_socket_path is not None:
90-
client = redis.StrictRedis(unix_socket_path=unix_socket_path, password=password)
91+
client = redis.StrictRedis(unix_socket_path=unix_socket_path, username=user, password=password)
9192
else:
92-
client = redis.StrictRedis(host=host, port=port, password=password)
93+
client = redis.StrictRedis(host=host, port=port, username=user, password=password)
9394
except redis.exceptions.ConnectionError as e:
9495
print("Could not connect to Redis server.")
9596
raise e

redisgraph_bulk_loader/bulk_update.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def process_update_csv(self):
107107
@click.option('--host', '-h', default='127.0.0.1', help='Redis server host')
108108
@click.option('--port', '-p', default=6379, help='Redis server port')
109109
@click.option('--password', '-a', default=None, help='Redis server password')
110+
@click.option('--user', '-w', default=None, help='Username for Redis ACL')
110111
@click.option('--unix-socket-path', '-u', default=None, help='Redis server unix socket path')
111112
# Cypher query options
112113
@click.option('--query', '-q', help='Query to run on server')
@@ -117,7 +118,7 @@ def process_update_csv(self):
117118
@click.option('--no-header', '-n', default=False, is_flag=True, help='If set, the CSV file has no header')
118119
# Buffer size restrictions
119120
@click.option('--max-token-size', '-t', default=500, help='Max size of each token in megabytes (default 500, max 512)')
120-
def bulk_update(graph, host, port, password, unix_socket_path, query, variable_name, csv, separator, no_header, max_token_size):
121+
def bulk_update(graph, host, port, password, user, unix_socket_path, query, variable_name, csv, separator, no_header, max_token_size):
121122
if sys.version_info[0] < 3:
122123
raise Exception("Python 3 is required for the RedisGraph bulk updater.")
123124

@@ -126,9 +127,9 @@ def bulk_update(graph, host, port, password, unix_socket_path, query, variable_n
126127
# Attempt to connect to Redis server
127128
try:
128129
if unix_socket_path is not None:
129-
client = redis.StrictRedis(unix_socket_path=unix_socket_path, password=password, decode_responses=True)
130+
client = redis.StrictRedis(unix_socket_path=unix_socket_path, username=user, password=password, decode_responses=True)
130131
else:
131-
client = redis.StrictRedis(host=host, port=port, password=password, decode_responses=True)
132+
client = redis.StrictRedis(host=host, port=port, username=user, password=password, decode_responses=True)
132133
except redis.exceptions.ConnectionError as e:
133134
print("Could not connect to Redis server.")
134135
raise e

0 commit comments

Comments
 (0)