Download sqlite.py from Haodan/textToSQL: direct link, hf CLI and curl.
- Browser
- Download file 992 Bytes
-
https://huggingface.co/spaces/Haodan/textToSQL/resolve/main/sqlite.py
- Command line
-
hf download hf://spaces/Haodan/textToSQL/sqlite.py
-
curl -L -o sqlite.py https://huggingface.co/spaces/Haodan/textToSQL/resolve/main/sqlite.py
992 Bytes
| import sqlite3 | |
| ## Connect to SQlite | |
| connection=sqlite3.connect('student.db') | |
| ## Create a cursor object to insert record, create table | |
| cursor=connection.cursor() | |
| ## Create the table | |
| table_info=""" | |
| Create table STUDENT(NAME VARCHAR(25), CLASS VARCHAR(25), SECTION VARCHAR(25), MARKS INT); | |
| """ | |
| cursor.execute(table_info) | |
| ## Insert some records | |
| cursor.execute('''Insert Into STUDENT values('Chris','Data Science', 'A', 91)''') | |
| cursor.execute('''Insert Into STUDENT values('Ashley','Data Science', 'B', 86)''') | |
| cursor.execute('''Insert Into STUDENT values('Alex','Data Science', 'A', 99)''') | |
| cursor.execute('''Insert Into STUDENT values('Doris','Software Development', 'A', 71)''') | |
| cursor.execute('''Insert Into STUDENT values('Wong','Software Development', 'B', 52)''') | |
| ## Display all the records | |
| print("The inserted records are:") | |
| data=cursor.execute('''Select * from STUDENT''') | |
| for row in data: | |
| print(row) | |
| ## Commit the changes in the database | |
| connection.commit() | |
| connection.close() |