-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
34 lines (30 loc) · 855 Bytes
/
Copy pathdatabase.py
File metadata and controls
34 lines (30 loc) · 855 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
import sqlite3
def create_table():
conn = sqlite3.connect('cs2_skins.db')
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS cs2_skins (
id INTEGER PRIMARY KEY AUTOINCREMENT,
item_name TEXT,
lowest_price TEXT,
volume TEXT,
median_price TEXT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
)
''')
conn.commit()
conn.close()
def store_price_data(item_name, price_data):
conn = sqlite3.connect('cs2_skins.db')
cursor = conn.cursor()
cursor.execute('''
INSERT INTO cs2_skins (item_name, lowest_price, volume, median_price)
VALUES (?, ?, ?, ?)
''', (
item_name,
price_data.get('lowest_price'),
price_data.get('volume'),
price_data.get('median_price')
))
conn.commit()
conn.close()