-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
62 lines (43 loc) · 2.2 KB
/
test.py
File metadata and controls
62 lines (43 loc) · 2.2 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
61
62
#!/usr/bin/env python3
import sys, os
sys.path.append(os.path.abspath("connectwrap"))
from connectwrap import db; import utils
# Create demo.db database file.
utils.create_database("demo.db")
# Create object representing the demo.db file database.
demo_database = db("demo.db")
# Create table Crew in the demo.db database file with the desired keys and types as kwargs.
demo_database.create_table("Crew", crew_id = "int", first_name = "str", last_name = "str", age = "int", position = "str")
# Set the db_table attribute to point to the Crew table.
demo_database.set_db_table("Crew")
# Insert rows/tuples of records in the Crew table.
demo_database.insert_row(0, "Jean-Luc", "Picard", 59, "Captain")
demo_database.insert_row(1, "William", "Riker", 29, "Commander")
demo_database.insert_row(2, "Beverly", "Crusher", 40, "Commander Doctor")
demo_database.insert_row(3, "Data", "Soong", 26, "Lieutenant Commander")
demo_database.insert_row(4, "Deanna", "Troi", 28, "Lieutenant Commander Counselor")
demo_database.insert_row(5, "Geordi", "LaForge", 29, "Lieutenant Junior Grade")
demo_database.insert_row(6, "Worf", "Son of Mogh", 24, "Lieutenant Junior Grade")
demo_database.insert_row(7, "Wesley", "Crusher", 16, "Ensign")
# Select table names from database and output them to terminal.
demo_database.select_tablenames()
# Select key values from Crew table and output them to terminal.
demo_database.select_keys()
# Update columns from rows based on desired criteria.
demo_database.update_row("position", "Lieutenant", "crew_id", 5)
# Select a specific row with key/value args and delete.
demo_database.drop_row("first_name", "Wesley")
# Select row values in Crew table and output them to terminal.
demo_database.select_table()
# Select top 3 row values in Crew table and output them to terminal.
demo_database.select_top(3)
# Select column values by key first_name and output them to terminal.
demo_database.select_column("first_name")
# Select a specific row with the key/value args and output to terminal.
demo_database.select_row("position", "Captain")
# Delete the Crew table.
demo_database.drop_table("Crew")
# Close the database.
demo_database.close_db()
# Delete demo.db database file.
utils.drop_database("demo.db")