|
1 | | -import ssl |
2 | 1 | import sys |
3 | 2 | from timeit import default_timer as timer |
4 | 3 |
|
@@ -51,17 +50,9 @@ def process_entities(entities): |
51 | 50 | @click.command() |
52 | 51 | @click.argument("graph") |
53 | 52 | # Redis server connection settings |
54 | | -@click.option("--host", "-h", default="127.0.0.1", help="Redis server host") |
55 | | -@click.option("--port", "-p", default=6379, help="Redis server port") |
56 | | -@click.option("--password", "-a", default=None, help="Redis server password") |
57 | | -@click.option("--user", "-w", default=None, help="Username for Redis ACL") |
58 | 53 | @click.option( |
59 | | - "--unix-socket-path", "-u", default=None, help="Redis server unix socket path" |
| 54 | + "--redis-url", "-u", default="redis://127.0.0.1:6379", help="Redis connection url" |
60 | 55 | ) |
61 | | -@click.option("--ssl-keyfile", "-k", default=None, help="SSL keyfile") |
62 | | -@click.option("--ssl-certfile", "-l", default=None, help="SSL certfile") |
63 | | -@click.option("--ssl-ca-certs", "-m", default=None, help="SSL CA certs") |
64 | | -# CSV file paths |
65 | 56 | @click.option("--nodes", "-n", multiple=True, help="Path to node csv file") |
66 | 57 | @click.option( |
67 | 58 | "--nodes-with-label", |
@@ -151,14 +142,7 @@ def process_entities(entities): |
151 | 142 | ) |
152 | 143 | def bulk_insert( |
153 | 144 | graph, |
154 | | - host, |
155 | | - port, |
156 | | - password, |
157 | | - user, |
158 | | - unix_socket_path, |
159 | | - ssl_keyfile, |
160 | | - ssl_certfile, |
161 | | - ssl_ca_certs, |
| 145 | + redis_url, |
162 | 146 | nodes, |
163 | 147 | nodes_with_label, |
164 | 148 | relations, |
@@ -202,25 +186,11 @@ def bulk_insert( |
202 | 186 | escapechar, |
203 | 187 | ) |
204 | 188 |
|
205 | | - kwargs = {"host": host, "port": port, "username": user, "password": password} |
206 | | - |
207 | | - if unix_socket_path is not None: |
208 | | - kwargs.update({"unix_socket_path": unix_socket_path}) |
209 | | - |
210 | | - if ssl_keyfile or ssl_certfile or ssl_ca_certs: |
211 | | - kwargs.update( |
212 | | - { |
213 | | - "ssl": True, |
214 | | - "ssl_keyfile": ssl_keyfile, |
215 | | - "ssl_certfile": ssl_certfile, |
216 | | - "ssl_cert_reqs": ssl.CERT_REQUIRED, |
217 | | - "ssl_ca_certs": ssl_ca_certs, |
218 | | - } |
219 | | - ) |
| 189 | + client = redis.from_url(redis_url) |
220 | 190 |
|
221 | 191 | # Attempt to connect to Redis server |
222 | 192 | try: |
223 | | - client = redis.Redis(**kwargs) |
| 193 | + client.ping() |
224 | 194 | except redis.exceptions.ConnectionError as e: |
225 | 195 | print("Could not connect to Redis server.") |
226 | 196 | raise e |
|
0 commit comments