Skip to content

Commit

Permalink
add graph_name re;
Browse files Browse the repository at this point in the history
  • Loading branch information
KingSkyLi committed Aug 22, 2024
1 parent 998ee56 commit e24455e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dbgpt/datasource/conn_tugraph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""TuGraph Connector."""

import json
import json, re
from typing import Dict, List, cast, Union, Generator

from .base import BaseConnector
Expand All @@ -23,6 +23,10 @@ def __init__(self, driver, graph):
def create_graph(self, graph_name: str) -> None:
"""Create a new graph."""
# run the query to get vertex labels

if not re.match(r"^[a-zA-Z\u4e00-\u9fff]", graph_name):
raise ValueError("Graph name must start with a letter or Chinese character, and cannot begin with a number or special character.")

with self._driver.session(database="default") as session:
graph_list = session.run("CALL dbms.graph.listGraphs()").data()
exists = any(item["graph_name"] == graph_name for item in graph_list)
Expand Down

0 comments on commit e24455e

Please sign in to comment.