from dotenv import load_dotenv load_dotenv() import streamlit as st import os import sqlite3 import google.generativeai as genai genai.configure(api_key = os.getenv("GOOGLE_API_KEY")) def get_gemini_response(question, prompt): model = genai.GenerativeModel('gemini-pro') response = model.generate_content([prompt, question]) return response.text def read_sql_query(sql, db): conn = sqlite3.connect(db) curr = conn.cursor() curr.execute(sql) rows = curr.fetchall() conn.commit() conn.close() for row in rows: print(row[0]) return rows prompt = """You are an expert in converting english text to SQL query. I have a database with table named Student & have columns as Name, Class, Section. Please help me with this task. Sql code should not have these signs ``` before and after query. """ st.set_page_config(page_title="I can retrieve any SQL query") st.header("Gemini App to retrieve SQL Data") question = st.text_input("Input: ", key='input') submit = st.button("Ask the question") if submit: response = get_gemini_response(question, prompt) response = read_sql_query(response, 'student.db') st.subheader("The Response is: ") for row in response: print(response) print(row) st.header(row[0])