Skip to content

Commit

Permalink
fix: postgres connection succeed
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav274 committed Sep 20, 2023
1 parent bda60d8 commit 997168a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions superagi/tools/eva_db/db_create_connection_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,17 @@ def _execute(self, db_engine: str, username: str, host: str, port: str, database
cursor = evadb.connect().cursor()
db_connection_name = db_engine + '__' + database_name
create_db_query = """
CREATE DATABASE {connection_name} WITH ENGINE = '{db_engine}', PARAMETERS = {{
CREATE DATABASE IF NOT EXISTS {connection_name} WITH ENGINE = '{db_engine}', PARAMETERS = {{
"user": "{username}",
"host": "{hostname}",
"port": "{port}",
"database": "{db_name}",
"password": "{password}"
}};
""".format(connection_name = db_connection_name, db_engine = db_engine, username = username,
hostname = host, port = port, db_name = database_name, password = "dbpass")
hostname = host, port = port, db_name = database_name, password = "ada@Gatech")
print("create_db_query", create_db_query)
ret = cursor.query(create_db_query).execute()
#cursor.query(f"DROP DATABASE IF EXISTS {db_connection_name}").df()
ret = cursor.query(create_db_query).df()
cursor.close()
return "Sucessfully created the desired connection to underlying databse engine with name {connection}. This connection can now be used to query requested database.".format(connection = db_connection_name)
return "Sucessfully created the desired connection to underlying databse engine with name {connection}. This connection can now be used to query requested database.".format(connection = db_connection_name)
6 changes: 3 additions & 3 deletions superagi/tools/eva_db/db_query_connection_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def _execute(self, db_connection: str, query: str) -> tuple:

print("FINAL_QUERY: ", db_query)
cursor = evadb.connect().cursor()
ret = cursor.query(db_query).execute()
ret = cursor.query(db_query).df()
print(ret)
cursor.close()

return ("Successfully executed the provided query", "result: " + ret)

return ("Successfully executed the provided query", "result: " + ret.to_string())

0 comments on commit 997168a

Please sign in to comment.