-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.py
More file actions
29 lines (24 loc) · 802 Bytes
/
helpers.py
File metadata and controls
29 lines (24 loc) · 802 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
import include
# this file is just a couple functions to clear the tables so I dont have to keep typing everything out becacuse im lazy
def create_server_connection():
try:
mydb = include.sql.connect('data.db')
print("Connection Successful")
except include.sql.Error as err:
print(f"Error: '{err}")
return mydb
def clear_table():
connect = create_server_connection()
mouse = connect.cursor()
mouse.execute("DELETE FROM news;")
sel = mouse.execute("SELECT * FROM news;")
connect.commit()
if sel:
print("Table Clear")
else:
print("Try Again: ", sel.fetchall())
def get_all():
connect = create_server_connection()
mouse = connect.cursor()
sel = mouse.execute("SELECT * FROM news;")
print(sel.fetchall())