mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-22 19:51:02 +02:00
parent
80ca41f8d2
commit
44bbfc1473
1 changed files with 9 additions and 2 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
from cassandra.cluster import Cluster
|
from cassandra.cluster import Cluster
|
||||||
from cassandra.auth import PlainTextAuthProvider
|
from cassandra.auth import PlainTextAuthProvider
|
||||||
from cassandra.query import BatchStatement, SimpleStatement
|
from cassandra.query import BatchStatement, SimpleStatement
|
||||||
|
|
@ -548,7 +548,7 @@ class EntityCentricKnowledgeGraph:
|
||||||
if hosts is None:
|
if hosts is None:
|
||||||
hosts = ["localhost"]
|
hosts = ["localhost"]
|
||||||
|
|
||||||
self.keyspace = keyspace
|
self.keyspace = self.sanitize_name(keyspace)
|
||||||
self.replication_factor = replication_factor
|
self.replication_factor = replication_factor
|
||||||
self.username = username
|
self.username = username
|
||||||
|
|
||||||
|
|
@ -572,6 +572,13 @@ class EntityCentricKnowledgeGraph:
|
||||||
|
|
||||||
self.init()
|
self.init()
|
||||||
self.prepare_statements()
|
self.prepare_statements()
|
||||||
|
|
||||||
|
def sanitize_name(self, name: str) -> str:
|
||||||
|
"""Sanitize names for Cassandra compatibility"""
|
||||||
|
safe_name = re.sub(r'[^a-zA-Z0-9_]', '_', name)
|
||||||
|
if safe_name and not safe_name[0].isalpha():
|
||||||
|
safe_name = 'r_' + safe_name
|
||||||
|
return safe_name.lower()
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self.session.execute(f"""
|
self.session.execute(f"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue