#Connect Open Interpreter to my database

23 messages · Page 1 of 1 (latest)

chrome ice
#

Folks, Learning the capabilities of Open Interpreter.Quick question ,Can the application connect to my application database to query and perform predictive analysis @feral oxide any suggestions

feral oxide
#

Give OI the database credentials and see! If you can connect to it with code, you should be able to connect to it with OI, you just need to help it out

chrome ice
#

if it works then it is revolutiionary .BTW yo have not checked my Openinterpreter running as the server yet ,your logins have been created

#

Thanks for your suggestions

chrome ice
#

@feral oxide The connection to the PostgreSQL database was successful this time. This means that the credentials provided are correct and the database server is running and accepting connections.

If you need to perform any operations on the database, such as querying data or updating records, you can provide the necessary SQL statements and I can execute them for you. Good sign at least it connect to the data base ,now is there an inbuilt funtionality that instead of sending sql commands the data is fetched using normal business language .Thanks for your guidance

lunar fossil
#

thats a really cool use case so i put it to the test
looks like it works really well, it can connect to my database and answer natural quesions about the data

chrome ice
#

@lunar fossil was wondringif there is solution to interact using normal business english commands as oppossed to SQL

lunar fossil
#

i am interacting with normal english. is there any reason in particular interpreter converting natural language to sql and back isnt sufficient for your use case?

chrome ice
#

@lunar fossil very interesting I guess the first interaction has to be SQLbased. I have a Transformation application running and wanto list down aciton itmes asssigned to a user .I guess I cannot list down all the aciton items assigned to a person by using plain enaglish ."Can you please ist down all the action items "

lunar fossil
#

i dont see why that wouldn't work. have you tried it and run into an issue?

chrome ice
#

@lunar fossil Fantastic! The query executed successfully, and we were able to retrieve the current date and time from your PostgreSQL database. This confirms that we have established a valid connection to your database.

Remember to close the database connection when you're done to free up resources. You can do this by calling conn.close() in Python.

If you have any other tasks or queries related to your database or anything else, feel free to ask!

Please list down all users in Demo Project

To list down all the users in the "Demo Project", we need to know the structure of your database. Specifically, we need to know the table that contains the information about the projects and users.

However, assuming there's a table named "users" that has a column "project" where the project name is stored, we can fetch all users in the "Demo Project" by executing an SQL query.

Here's the plan:

Write an SQL query to fetch all users from the "users" table where the project is "Demo Project".
Execute the query using the psycopg2 module.
Fetch all rows from the result of the query.
Print the fetched rows.
Let's proceed with the first step and write the SQL query.

sql_query = 'SELECT * FROM users WHERE project =

Cell In[3], line 1
sql_query = 'SELECT * FROM users WHERE project =
^
SyntaxError: unterminated string literal (detected at line 1)
No output available on console.

It appears that there was an error because the SQL query string was not properly terminated. Let's correct that and try again. We need to complete the SQL query to fetch all users from the "users" table where the project is "Demo Project".

lunar fossil
#

what model are you using?

chrome ice
#

GPT 4

lunar fossil
#

4o or just gpt-4? did it correct itself after?

chrome ice
#

GPT 4

lunar fossil
#

try --model gpt-4o
i find its better at planning and correcting

chrome ice
#

Do you know how to turn off the code execution from screen

lunar fossil
#

im not sure if theres an option to hide it currently, thats an idea
but if you launch with -y it wont ask you every time theres code to execute

#

maybe when you start off, ask it to look at the structure of the tables in the database

chrome ice
#

ok thanks

chrome ice
#

@lunar fossil I amrunning openinterpreter as a server application .i do not think that should be a problem

feral oxide
#

I was also able to get this to work. Good job @chrome ice!