I wanted to create a Python file that has multiple functions for creating graphs, nodes and edges. The code that I wrote only includes the function for creating a graph:
import psycopg2
GRAPH_NAME = "test_graph"
conn = psycopg2.connect(host="localhost", port="5432", dbname="demo", user="postgres", password="password")
def create_graph(graph_name):
with conn.cursor() as cursor:
try:
cursor.execute("SELECT * FROM ag_catalog.create_graph(%s);", (graph_name,))
conn.commit
except Exception as ex:
print(type(ex), ex)
conn.rollback()
create_graph('testing_py')
But, when I run it, the graph is not created and it throws no errors. What is the proper way to create graphs via python scripts?