Spaces:
Build error
Build error
Commit
·
46be47d
1
Parent(s):
7c11b62
creat database and app
Browse files- app.py +71 -0
- database/create_student_db.py +210 -0
- database/student.db +0 -0
- requirements.txt +3 -0
- setup.py +29 -0
app.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import sqlite3
|
| 4 |
+
import google.generativeai as genai
|
| 5 |
+
|
| 6 |
+
# Configure API key
|
| 7 |
+
genai.configure(api_key=st.secrets["GOOGLE_API_KEY"])
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# Function to load Gemini Model and provide SQL query as response
|
| 11 |
+
def get_gemini_response(prompt, question):
|
| 12 |
+
# model = genai.GenerativeModel("gemini-1.5-flash")
|
| 13 |
+
model = genai.GenerativeModel("gemini-pro")
|
| 14 |
+
response = model.generate_content([prompt[0], question])
|
| 15 |
+
return response.text
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# Function to retrieve query from the SQL database
|
| 19 |
+
def read_sql_query(sql, db):
|
| 20 |
+
connection = sqlite3.connect(db)
|
| 21 |
+
cursor = connection.cursor()
|
| 22 |
+
cursor.execute(sql)
|
| 23 |
+
rows = cursor.fetchall()
|
| 24 |
+
connection.commit()
|
| 25 |
+
connection.close()
|
| 26 |
+
|
| 27 |
+
for row in rows:
|
| 28 |
+
print(row)
|
| 29 |
+
return rows
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
# Define prompt
|
| 33 |
+
prompt = [
|
| 34 |
+
"""
|
| 35 |
+
You are an expert in converting English questions to SQL query!
|
| 36 |
+
The SQL database has 4 tables include STUDENT, LECTURER, COURSE, REGISTRATION FORM.
|
| 37 |
+
STUDENT has the following columns - ID_STU(primary key), NAME_STU, BIRTHDAY_STU and BIRTHPLACE_STU.
|
| 38 |
+
LECTURER has the following columns - ID_LEC(primary key), NAME_LEC, BIRTHDAY_LEC and BIRTHPLACE_LEC.
|
| 39 |
+
COURSE has the following columns - ID_COU(primary key), NAME_COU, ID_LEC(foreign key references LECTURER(ID_LEC)).
|
| 40 |
+
REGISTRATION_FORM has the following columns - ID_REG(primary key), ID_COU(foreign key references COURSE(ID_COU)), ID_STU(foreign key references STUDENT(ID_STU)).
|
| 41 |
+
|
| 42 |
+
For example,
|
| 43 |
+
Example 1 - How many entries of STUDENT table are present?,
|
| 44 |
+
the SQL command will be something like this SELECT COUNT(*) FROM STUDENT;
|
| 45 |
+
Example 2 - Tell me all the students having birthplace Hải Phòng?,
|
| 46 |
+
the SQL command will be something like this SELECT * FROM STUDENT WHERE BIRTHPLACE = 'Hải Phòng';
|
| 47 |
+
Example 3 - Tell me all the course lecturer Đặng Quốc Việt teaching?,
|
| 48 |
+
the SQL command will be something like this SELECT B.NAME_COU FROM LECTURER A JOIN COURSE B ON A.ID_LEC = B.ID_LEC WHERE A.NAME_LEC = 'Đặng Quốc Việt';
|
| 49 |
+
Example 4- Tell me all the students studying 2 or more classes?,
|
| 50 |
+
the SQL command will be something like this SELECT A.NAME_STU FROM STUDENT A JOIN REGISTRATION_FORM B ON A.ID_STU = B.ID_STU GROUP BY A.NAME_STU HAVING COUNT(B.ID_COU) > 1;
|
| 51 |
+
|
| 52 |
+
note that the SQL code must not start and end with ``` and must not contain the "sql" word in output.
|
| 53 |
+
"""
|
| 54 |
+
]
|
| 55 |
+
|
| 56 |
+
# Streamlit App
|
| 57 |
+
st.set_page_config(page_title="Text to SQL")
|
| 58 |
+
st.header("Gemini App to Retrieve SQL Data")
|
| 59 |
+
|
| 60 |
+
question = st.text_input("Input", key="input")
|
| 61 |
+
submit = st.button("Ask the question")
|
| 62 |
+
|
| 63 |
+
# If submit is clicked
|
| 64 |
+
if submit:
|
| 65 |
+
response = get_gemini_response(prompt, question)
|
| 66 |
+
print(response)
|
| 67 |
+
|
| 68 |
+
data = read_sql_query(response, "database/student.db")
|
| 69 |
+
st.subheader("Result")
|
| 70 |
+
for row in data:
|
| 71 |
+
st.subheader(row)
|
database/create_student_db.py
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sqlite3
|
| 2 |
+
|
| 3 |
+
# Connect to sqlite
|
| 4 |
+
connection = sqlite3.connect("database/student.db")
|
| 5 |
+
|
| 6 |
+
# Create a cursor object to create table, insert record and retrieve
|
| 7 |
+
cursor = connection.cursor()
|
| 8 |
+
|
| 9 |
+
# Create the table
|
| 10 |
+
table_info = """ create table if not exists STUDENT (
|
| 11 |
+
ID_STU integer primary key not null,
|
| 12 |
+
NAME_STU nvarchar(30),
|
| 13 |
+
BIRTHDAY_STU date,
|
| 14 |
+
BIRTHPLACE_STU nvarchar(100))"""
|
| 15 |
+
cursor.execute(table_info)
|
| 16 |
+
|
| 17 |
+
table_info = """ create table if not exists LECTURER (
|
| 18 |
+
ID_LEC integer primary key not null,
|
| 19 |
+
NAME_LEC nvarchar(30),
|
| 20 |
+
BIRTHDAY_LEC date,
|
| 21 |
+
BIRTHPLACE_LEC nvarchar(100))"""
|
| 22 |
+
cursor.execute(table_info)
|
| 23 |
+
|
| 24 |
+
table_info = """create table if not exists COURSE (
|
| 25 |
+
ID_COU integer primary key not null,
|
| 26 |
+
NAME_COU nvarchar(100),
|
| 27 |
+
ID_LEC integer,
|
| 28 |
+
foreign key (ID_LEC) references LECTURER(ID_LEC))"""
|
| 29 |
+
cursor.execute(table_info)
|
| 30 |
+
|
| 31 |
+
table_info = """create table if not exists REGISTRATION_FORM (
|
| 32 |
+
ID_REG integer primary key not null,
|
| 33 |
+
ID_COU integer,
|
| 34 |
+
ID_STU integer,
|
| 35 |
+
foreign key (ID_COU) references COURSE(ID_COU),
|
| 36 |
+
foreign key (ID_STU) references STUDENT(ID_STU))"""
|
| 37 |
+
cursor.execute(table_info)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
# Insert some records
|
| 41 |
+
connection.execute("PRAGMA foreign_keys = ON")
|
| 42 |
+
|
| 43 |
+
cursor.execute(
|
| 44 |
+
"""insert into STUDENT values (1, 'Đặng Tuấn Anh','1999-08-08', 'Hải Phòng');"""
|
| 45 |
+
)
|
| 46 |
+
cursor.execute(
|
| 47 |
+
"""insert into STUDENT values (2, 'Hoàng Đức Anh','1999-08-09', 'Hà Nội');"""
|
| 48 |
+
)
|
| 49 |
+
cursor.execute(
|
| 50 |
+
"""insert into STUDENT values (3, 'Lưu Trang Anh','1999-08-10', 'Bắc Ninh');"""
|
| 51 |
+
)
|
| 52 |
+
cursor.execute(
|
| 53 |
+
"""insert into STUDENT values (4, 'Phạm Hoàng Anh','2000-08-11', 'Nam Định');"""
|
| 54 |
+
)
|
| 55 |
+
cursor.execute(
|
| 56 |
+
"""insert into STUDENT values (5, 'Phạm Thị Hiền Anh','2000-07-12', 'Hưng Yên');"""
|
| 57 |
+
)
|
| 58 |
+
cursor.execute(
|
| 59 |
+
"""insert into STUDENT values (6, 'Phạm Khắc Việt Anh','2000-07-13', 'Hải Phòng');"""
|
| 60 |
+
)
|
| 61 |
+
cursor.execute(
|
| 62 |
+
"""insert into STUDENT values (7, 'Đỗ Hoàng Gia Bảo','2000-07-14', 'Hà Nội');"""
|
| 63 |
+
)
|
| 64 |
+
cursor.execute(
|
| 65 |
+
"""insert into STUDENT values (8, 'Trần Thị Minh Châu','1998-07-15', 'Bắc Ninh');"""
|
| 66 |
+
)
|
| 67 |
+
cursor.execute(
|
| 68 |
+
"""insert into STUDENT values (9, 'Tăng Phương Chi','1998-09-16', 'Nam Định');"""
|
| 69 |
+
)
|
| 70 |
+
cursor.execute(
|
| 71 |
+
"""insert into STUDENT values (10, 'Gan Feng Du','1998-09-17', 'Hưng Yên');"""
|
| 72 |
+
)
|
| 73 |
+
cursor.execute(
|
| 74 |
+
"""insert into STUDENT values (11, 'Phạm Tiến Dũng','1998-09-19', 'Hải Phòng');"""
|
| 75 |
+
)
|
| 76 |
+
cursor.execute(
|
| 77 |
+
"""insert into STUDENT values (12, 'Nguyễn Thái Dương','1997-09-19', 'Hà Nội');"""
|
| 78 |
+
)
|
| 79 |
+
cursor.execute(
|
| 80 |
+
"""insert into STUDENT values (13, 'Trần An Dương','1997-05-20', 'Bắc Ninh');"""
|
| 81 |
+
)
|
| 82 |
+
cursor.execute(
|
| 83 |
+
"""insert into STUDENT values (14, 'Mạc Trung Đức','1997-05-21', 'Nam Định');"""
|
| 84 |
+
)
|
| 85 |
+
cursor.execute(
|
| 86 |
+
"""insert into STUDENT values (15, 'Vũ Hương Giang','1997-05-22', 'Hưng Yên');"""
|
| 87 |
+
)
|
| 88 |
+
cursor.execute(
|
| 89 |
+
"""insert into STUDENT values (16, 'Nguyễn Thị Ngân Hà','1997-01-23', 'Hải Phòng');"""
|
| 90 |
+
)
|
| 91 |
+
cursor.execute(
|
| 92 |
+
"""insert into STUDENT values (17, 'Nguyễn Lê Hiếu','1996-01-24', 'Hà Nội');"""
|
| 93 |
+
)
|
| 94 |
+
cursor.execute(
|
| 95 |
+
"""insert into STUDENT values (18, 'Phạm Xuân Hòa','1996-01-25', 'Bắc Ninh');"""
|
| 96 |
+
)
|
| 97 |
+
cursor.execute(
|
| 98 |
+
"""insert into STUDENT values (19, 'Khoa Minh Hoàng','1996-01-26', 'Nam Định');"""
|
| 99 |
+
)
|
| 100 |
+
cursor.execute(
|
| 101 |
+
"""insert into STUDENT values (20, 'Nguyễn Hữu Hiệp Hoàng','1996-01-27', 'Hưng Yên');"""
|
| 102 |
+
)
|
| 103 |
+
cursor.execute(
|
| 104 |
+
"""insert into STUDENT values (21, 'Nguyễn Văn A', '2000-09-25', 'Hải Phòng')"""
|
| 105 |
+
)
|
| 106 |
+
cursor.execute("""insert into STUDENT (ID_STU, BIRTHPLACE_STU) values (22, 'Hà Nội')""")
|
| 107 |
+
|
| 108 |
+
cursor.execute(
|
| 109 |
+
"""insert into LECTURER values (1, 'Đặng Quốc Việt','1987-7-01', 'Hải Phòng');"""
|
| 110 |
+
)
|
| 111 |
+
cursor.execute(
|
| 112 |
+
"""insert into LECTURER values (2, 'Hoàng Văn Bảo','1987-7-02', 'Hà Nội');"""
|
| 113 |
+
)
|
| 114 |
+
cursor.execute(
|
| 115 |
+
"""insert into LECTURER values (3, 'Lưu Thanh Tuấn','1987-7-03', 'Bắc Ninh');"""
|
| 116 |
+
)
|
| 117 |
+
cursor.execute(
|
| 118 |
+
"""insert into LECTURER values (4, 'Hoàng Thị Thanh Mai','1987-7-04', 'Nam Định');"""
|
| 119 |
+
)
|
| 120 |
+
cursor.execute(
|
| 121 |
+
"""insert into LECTURER values (5, 'Nguyễn Quỳnh Hoa','1987-7-05', 'Hưng Yên');"""
|
| 122 |
+
)
|
| 123 |
+
cursor.execute(
|
| 124 |
+
"""insert into LECTURER values (6, 'Cao Thị Xuân Dung','1992-6-06', 'Hải Phòng');"""
|
| 125 |
+
)
|
| 126 |
+
cursor.execute(
|
| 127 |
+
"""insert into LECTURER values (7, 'Đỗ Hồng Việt','1992-6-07', 'Hà Nội');"""
|
| 128 |
+
)
|
| 129 |
+
cursor.execute(
|
| 130 |
+
"""insert into LECTURER values (8, 'Phạm Thị Thu Hương','1992-6-08', 'Bắc Ninh');"""
|
| 131 |
+
)
|
| 132 |
+
cursor.execute(
|
| 133 |
+
"""insert into LECTURER values (9, 'Bùi Thị Vân Thiện','1992-6-6', 'Nam Định');"""
|
| 134 |
+
)
|
| 135 |
+
cursor.execute(
|
| 136 |
+
"""insert into LECTURER values (10, 'Nguyễn Thị Thu Hiền','1990-5-10', 'Hưng Yên');"""
|
| 137 |
+
)
|
| 138 |
+
cursor.execute(
|
| 139 |
+
"""insert into LECTURER values (11, 'Nguyễn Thị Trà My','1990-5-11', 'Hải Phòng');"""
|
| 140 |
+
)
|
| 141 |
+
cursor.execute(
|
| 142 |
+
"""insert into LECTURER values (12, 'Trần Thị Thúy','1990-5-12', 'Hà Nội');"""
|
| 143 |
+
)
|
| 144 |
+
cursor.execute(
|
| 145 |
+
"""insert into LECTURER values (13, 'Trần Trọng Dũng','1990-5-13', 'Bắc Ninh');"""
|
| 146 |
+
)
|
| 147 |
+
cursor.execute(
|
| 148 |
+
"""insert into LECTURER values (14, 'Mạc Văn Việt','1990-1-14', 'Nam Định');"""
|
| 149 |
+
)
|
| 150 |
+
cursor.execute(
|
| 151 |
+
"""insert into LECTURER values (15, 'Bùi Thị Thu Hương','1993-1-15', 'Hưng Yên');"""
|
| 152 |
+
)
|
| 153 |
+
cursor.execute(
|
| 154 |
+
"""insert into LECTURER values (16, 'Nguyễn Văn Đạm','1993-1-16', 'Hải Phòng');"""
|
| 155 |
+
)
|
| 156 |
+
cursor.execute(
|
| 157 |
+
"""insert into LECTURER values (17, 'Lê Thị Hợi','1993-1-17', 'Hà Nội');"""
|
| 158 |
+
)
|
| 159 |
+
cursor.execute(
|
| 160 |
+
"""insert into LECTURER values (18, 'Phạm Văn Cường','1993-2-18', 'Bắc Ninh');"""
|
| 161 |
+
)
|
| 162 |
+
cursor.execute(
|
| 163 |
+
"""insert into LECTURER values (19, 'Khoa Năng Tùng','1991-2-19', 'Nam Định');"""
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
cursor.execute("""insert into COURSE values (1,'Tester basic',1);""")
|
| 167 |
+
cursor.execute("""insert into COURSE values (2,'Tester advance',2);""")
|
| 168 |
+
cursor.execute("""insert into COURSE values (3,'Automation test',1);""")
|
| 169 |
+
cursor.execute("""insert into COURSE values (4,'API testing',4);""")
|
| 170 |
+
cursor.execute("""insert into COURSE values (5,'DB testing',5);""")
|
| 171 |
+
cursor.execute("""insert into COURSE values (6,'Performance testing',3);""")
|
| 172 |
+
cursor.execute("""insert into COURSE values (7,'GUI testing',7);""")
|
| 173 |
+
cursor.execute("""insert into COURSE values (8,'Mobile testing',8);""")
|
| 174 |
+
cursor.execute("""insert into COURSE values (9,'Game testing',9);""")
|
| 175 |
+
|
| 176 |
+
cursor.execute("""insert into REGISTRATION_FORM values (1,1,1);""")
|
| 177 |
+
cursor.execute("""insert into REGISTRATION_FORM values (2,2,2);""")
|
| 178 |
+
cursor.execute("""insert into REGISTRATION_FORM values (3,3,3);""")
|
| 179 |
+
cursor.execute("""insert into REGISTRATION_FORM values (4,4,4);""")
|
| 180 |
+
cursor.execute("""insert into REGISTRATION_FORM values (5,5,5);""")
|
| 181 |
+
cursor.execute("""insert into REGISTRATION_FORM values (6,6,6);""")
|
| 182 |
+
cursor.execute("""insert into REGISTRATION_FORM values (7,7,7);""")
|
| 183 |
+
cursor.execute("""insert into REGISTRATION_FORM values (8,8,8);""")
|
| 184 |
+
cursor.execute("""insert into REGISTRATION_FORM values (9,9,9);""")
|
| 185 |
+
cursor.execute("""insert into REGISTRATION_FORM values (10,1,10);""")
|
| 186 |
+
cursor.execute("""insert into REGISTRATION_FORM values (11,2,11);""")
|
| 187 |
+
cursor.execute("""insert into REGISTRATION_FORM values (12,3,12);""")
|
| 188 |
+
cursor.execute("""insert into REGISTRATION_FORM values (13,4,13);""")
|
| 189 |
+
cursor.execute("""insert into REGISTRATION_FORM values (14,5,14);""")
|
| 190 |
+
cursor.execute("""insert into REGISTRATION_FORM values (15,6,15);""")
|
| 191 |
+
cursor.execute("""insert into REGISTRATION_FORM values (16,7,16);""")
|
| 192 |
+
cursor.execute("""insert into REGISTRATION_FORM values (17,8,17);""")
|
| 193 |
+
cursor.execute("""insert into REGISTRATION_FORM values (18,9,18);""")
|
| 194 |
+
cursor.execute("""insert into REGISTRATION_FORM values (19,1,19);""")
|
| 195 |
+
cursor.execute("""insert into REGISTRATION_FORM values (20,2,20);""")
|
| 196 |
+
cursor.execute("""insert into REGISTRATION_FORM values (21,3,1);""")
|
| 197 |
+
cursor.execute("""insert into REGISTRATION_FORM values (22,4,2);""")
|
| 198 |
+
cursor.execute("""insert into REGISTRATION_FORM values (23,5,3);""")
|
| 199 |
+
cursor.execute("""insert into REGISTRATION_FORM values (24,6,4);""")
|
| 200 |
+
cursor.execute("""insert into REGISTRATION_FORM values (25,7,5);""")
|
| 201 |
+
cursor.execute("""insert into REGISTRATION_FORM values (26,8,6);""")
|
| 202 |
+
cursor.execute("""insert into REGISTRATION_FORM values (27,9,7);""")
|
| 203 |
+
cursor.execute("""insert into REGISTRATION_FORM values (28,1,8);""")
|
| 204 |
+
cursor.execute("""insert into REGISTRATION_FORM values (29,2,9);""")
|
| 205 |
+
cursor.execute("""insert into REGISTRATION_FORM values (30,3,10);""")
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
# Close the connection
|
| 209 |
+
connection.commit()
|
| 210 |
+
connection.close()
|
database/student.db
ADDED
|
Binary file (20.5 kB). View file
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
google-generativeai
|
| 3 |
+
# -e .
|
setup.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from setuptools import find_packages, setup
|
| 2 |
+
from typing import List
|
| 3 |
+
|
| 4 |
+
HYPHEN_E_DOT = "-e ."
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def get_requirements(file_path: str) -> List[str]:
|
| 8 |
+
"""
|
| 9 |
+
this function will return the list of requirements
|
| 10 |
+
"""
|
| 11 |
+
requirements = []
|
| 12 |
+
with open(file_path) as file_obj:
|
| 13 |
+
requirements = file_obj.readlines()
|
| 14 |
+
requirements = [req.replace("\n", "") for req in requirements]
|
| 15 |
+
|
| 16 |
+
if HYPHEN_E_DOT in requirements:
|
| 17 |
+
requirements.remove(HYPHEN_E_DOT)
|
| 18 |
+
|
| 19 |
+
return requirements
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
setup(
|
| 23 |
+
name="text-to-sql",
|
| 24 |
+
version="0.0.1",
|
| 25 |
+
author="Alain De Long",
|
| 26 |
+
author_email="leholong007@gmail.com",
|
| 27 |
+
packages=find_packages(),
|
| 28 |
+
install_requires=get_requirements("requirements.txt"),
|
| 29 |
+
)
|