mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-28 01:46:22 +02:00
Add user and password auth for Cassandra (#301)
This commit is contained in:
parent
1000a9de8f
commit
41ccb6c976
4 changed files with 89 additions and 13 deletions
|
|
@ -6,7 +6,7 @@ class TrustGraph:
|
|||
|
||||
def __init__(
|
||||
self, hosts=None,
|
||||
keyspace="trustgraph", table="default",
|
||||
keyspace="trustgraph", table="default", username=None, password=None
|
||||
):
|
||||
|
||||
if hosts is None:
|
||||
|
|
@ -14,8 +14,13 @@ class TrustGraph:
|
|||
|
||||
self.keyspace = keyspace
|
||||
self.table = table
|
||||
self.username = username
|
||||
|
||||
self.cluster = Cluster(hosts)
|
||||
if username and password:
|
||||
auth_provider = PlainTextAuthProvider(username=username, password=password)
|
||||
self.cluster = Cluster(hosts, auth_provider=auth_provider)
|
||||
else:
|
||||
self.cluster = Cluster(hosts)
|
||||
self.session = self.cluster.connect()
|
||||
|
||||
self.init()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue