Download sqllite.py from Praveenkumar07/Text_to_SQL_Generative_AI: direct link, hf CLI and curl.
- Browser
- Download file 959 Bytes
-
https://huggingface.co/spaces/Praveenkumar07/Text_to_SQL_Generative_AI/resolve/main/sqllite.py
- Command line
-
hf download hf://spaces/Praveenkumar07/Text_to_SQL_Generative_AI/sqllite.py
-
curl -L -o sqllite.py https://huggingface.co/spaces/Praveenkumar07/Text_to_SQL_Generative_AI/resolve/main/sqllite.py
959 Bytes
| import sqlite3 | |
| #connect to SQLlite | |
| connection=sqlite3.connect("student.db") | |
| #create a cursor to insert record,create table | |
| cursor=connection.cursor() | |
| #create a table | |
| table_info=""" | |
| Create table STUDENT(NAME VARCHAR(25),CLASS VARCHAR(25), | |
| SECTION VARCHAR(25)); | |
| """ | |
| #creating the table | |
| cursor.execute(table_info) | |
| #insert some more records | |
| cursor.execute("""Insert Into STUDENT values("Krish","Data Science","A")""") | |
| cursor.execute("""Insert Into STUDENT values("kayal","DevOps","A")""") | |
| cursor.execute("""Insert Into STUDENT values("david","Data Science","B")""") | |
| cursor.execute("""Insert Into STUDENT values("bala","DevOps","A")""") | |
| cursor.execute("""Insert Into STUDENT values("praveen","Data Science","B")""") | |
| #Display the records | |
| print("The inerted records are") | |
| data=cursor.execute("""select * from STUDENT""") | |
| for row in data: | |
| print(row) | |
| #commit the changes in db | |
| connection.commit() | |
| connection.close() |