Some headway on database stuff
This commit is contained in:
0
test/__init__.py
Normal file
0
test/__init__.py
Normal file
29
test/db_interface_test.py
Normal file
29
test/db_interface_test.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from utilities.database.sqlite import SQLite
|
||||
from pprint import pprint
|
||||
|
||||
test_db = SQLite("testdb.db")
|
||||
|
||||
test_db.query("CREATE TABLE vegetables (veggie_id INTEGER PRIMARY KEY AUTOINCREMENT, veggie_name TEXT NOT NULL)")
|
||||
|
||||
test_db.insert("vegetables", ["veggie_name"], ["Green Beans"])
|
||||
test_db.insert("vegetables", ["veggie_name"], ["Peas"])
|
||||
test_db.insert("vegetables", ["veggie_name"], ["Corn"])
|
||||
test_db.insert("vegetables", ["veggie_name"], ["Stephen Hawking"])
|
||||
|
||||
pprint(test_db.select("vegetables"))
|
||||
|
||||
pprint(test_db.update("vegetables", ["veggie_name"], ["Snow Peas", 2], [
|
||||
{
|
||||
"name": "veggie_id",
|
||||
"compare": "="
|
||||
}
|
||||
]))
|
||||
|
||||
pprint(test_db.delete("vegetables", [3], [
|
||||
{
|
||||
"name": "veggie_id",
|
||||
"compare": ">="
|
||||
}
|
||||
]))
|
||||
|
||||
pprint(test_db.select("vegetables"))
|
||||
Reference in New Issue
Block a user