File size: 764 Bytes
9d09bcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Importing the dependencies, loading the environment variables and congifuring any models/libraries
import sqlite3
from dotenv import load_dotenv
load_dotenv()

import os
import google.generativeai as genai

genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))

# Function to load the Google Gemini Model and provide the response

def get_gemini_response(question,prompt):
    model = genai.GenerativeModel('gemini-pro')
    response = model.generate_content([prompt[0],question])
    return response.text


# Function to retrieve query from the database

def read_sql_query(sql,db):
    con = sqlite3.connect(db)
    cur = con.cursor()
    
    cur.execute(sql)
    
    rows = cur.fetchall()
    
    for row in rows:
        print(row)
        
    return rows