-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlite_basics.py
More file actions
46 lines (33 loc) · 937 Bytes
/
Copy pathsqlite_basics.py
File metadata and controls
46 lines (33 loc) · 937 Bytes
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
33
34
35
36
37
38
39
40
41
42
43
44
45
#sqlite basics script to initialize databases, tables, and test cursor operations
import sqlite3
#table named documents
#if those tables already exists than delete their cursor.execute calls from below
#this was just for initating tables and test site of cursor
connection = sqlite3.connect('database-rag.db')
cursor = connection.cursor()
"""
cursor.execute('''
CREATE TABLE documents (
id INTEGER PRIMARY KEY AUTOINCREMENT,
text TEXT,
embedding BLOB,
distance REAL,
source TEXT,
approxcolorr REAL,
approxcolorg REAL,
approxcolorb REAL,
approxcolora REAL
)
''')
cursor.execute('''
CREATE TABLE queries(
query_id INTEGER PRIMARY KEY AUTOINCREMENT,
query_question TEXT,
query_answer TEXT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
)
''')
"""
print("Table created successfully.")
connection.commit()
connection.close()