CoolFace
Apppublic

SoumyaJ/DatabaseToolkitWithRAG

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
sqlite.py33 linesDownload Raw Back to root
1import sqlite3
2
3#create connection with sqlite 
4conn = sqlite3.connect("programme.db", check_same_thread= False)
5
6#create cursor to establish connection 
7cursor = conn.cursor()
8
9#create the table 
10prog_table_info = """
11CREATE TABLE programme(ProgrammeTitle nvarchar(500), ProgrammeStatus nvarchar(30), ProgrammeType nvarchar(30), Genre nvarchar(40), 
12SubGenre nvarchar(50), Language nvarchar(30), Duration nvarchar(30))
13"""
14cursor.execute(prog_table_info)
15
16print("Access the table programme")
17data = cursor.execute('''SELECT * from programme''')
18for row in data:
19    print(row)
20
21eps_table_info = """
22CREATE TABLE episode(EpisodeTitle nvarchar(500), EpisodeNumber int, Duration nvarchar(30))
23"""
24cursor.execute(eps_table_info)
25
26print("Access the table episode")
27data = cursor.execute('''SELECT * from episode''')
28for row in data:
29    print(row)
30
31conn.commit()
32conn.close()
33