-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclientDatabaseSystem.py
More file actions
60 lines (32 loc) · 1.01 KB
/
Copy pathclientDatabaseSystem.py
File metadata and controls
60 lines (32 loc) · 1.01 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import sqlite3
# Connect the physical cable to the database file
connection = sqlite3.Connection("clients.db")
# Create the invisible mechanic (cursor)
cursor = connection.cursor()
# Give the mechanic the SQL command to build the table
cursor.execute("""
CREATE TABLE IF NOT EXISTS USERS (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT
)
""")
# New code-block
# Send the technician out again to cram data into the table
cursor.execute("""
INSERT INTO USERS (username)
VALUES ('MASKY_Architect')
""")
# Send the mechanic (cursor) to request the entire table to view
cursor.execute("SELECT * FROM USERS")
# Pull all rows from the mechanic's hands
all_users = cursor.fetchall()
# Print the loot live in the Terminal
print("--- CONTENTS OF THE SQL DATABASE ---")
for user in all_users:
print(user)
print("-----------------------------")
# Press the save button
connection.commit()
# Disconnect the cable
connection.close()
print("SQL-Database and table build successfully!")