Skip to content

Commit 7fe76be

Browse files
committed
New/Open Database dialog options now default to default database location, Open Query option now defaults to last opened location. Editor line numbering now properly handles logical lines when wrapping occurs. Minor QoL enhancements: Query load now automatically normalizes Unix-style LF to Windows CRLF line endings. Ctrl+E bind added for execute, arrow key navigation now supported in text results, 'About' dialog moved to Help submenu.
1 parent 972d93a commit 7fe76be

12 files changed

Lines changed: 405 additions & 35 deletions

File tree

examples/inventory/queries.sql

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
-- Home Inventory Example Queries
2+
-- SQLite/CE Example
3+
4+
-- All items with room and category
5+
SELECT i.name, c.name AS category, r.name AS room, i.current_value
6+
FROM items i
7+
LEFT JOIN categories c ON i.category_id = c.id
8+
LEFT JOIN rooms r ON i.room_id = r.id
9+
ORDER BY r.name, i.name;
10+
11+
-- Total value by room
12+
SELECT r.name AS room, SUM(i.current_value) AS total_value
13+
FROM items i
14+
JOIN rooms r ON i.room_id = r.id
15+
GROUP BY r.id
16+
ORDER BY total_value DESC;
17+
18+
-- Total value by category
19+
SELECT c.name AS category, SUM(i.current_value) AS total_value
20+
FROM items i
21+
JOIN categories c ON i.category_id = c.id
22+
GROUP BY c.id
23+
ORDER BY total_value DESC;
24+
25+
-- Total inventory value
26+
SELECT SUM(current_value) AS total_value FROM items;
27+
28+
-- Items with expiring warranty (next 6 months)
29+
SELECT name, brand, model, warranty_expires
30+
FROM items
31+
WHERE warranty_expires IS NOT NULL
32+
AND warranty_expires <= '2026-07-01'
33+
AND warranty_expires >= '2026-01-01';
34+
35+
-- High value items (over $1000)
36+
SELECT name, brand, current_value, room_id
37+
FROM items
38+
WHERE current_value >= 1000
39+
ORDER BY current_value DESC;
40+
41+
-- Items with photos
42+
SELECT i.name, COUNT(p.id) AS photo_count
43+
FROM items i
44+
LEFT JOIN photos p ON i.item_id = p.item_id
45+
GROUP BY i.id
46+
HAVING photo_count > 0;
47+
48+
-- Electronics inventory
49+
SELECT i.name, i.brand, i.model, i.serial_number, i.current_value
50+
FROM items i
51+
JOIN categories c ON i.category_id = c.id
52+
WHERE c.name = 'Electronics';
53+
54+
-- Depreciation report (purchase vs current value)
55+
SELECT name, purchase_price, current_value,
56+
purchase_price - current_value AS depreciation
57+
FROM items
58+
WHERE purchase_price IS NOT NULL
59+
ORDER BY depreciation DESC;
60+
61+
62+
-- Using views
63+
SELECT * FROM v_items ORDER BY room, name;
64+
65+
SELECT * FROM v_room_totals ORDER BY total_value DESC;
66+
67+
SELECT * FROM v_warranty_expiring;

examples/inventory/sample_data.sql

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- Home Inventory Sample Data
2+
-- SQLite/CE Example
3+
4+
INSERT INTO rooms (id, name, floor) VALUES (1, 'Living Room', 1);
5+
INSERT INTO rooms (id, name, floor) VALUES (2, 'Kitchen', 1);
6+
INSERT INTO rooms (id, name, floor) VALUES (3, 'Master Bedroom', 2);
7+
INSERT INTO rooms (id, name, floor) VALUES (4, 'Office', 2);
8+
INSERT INTO rooms (id, name, floor) VALUES (5, 'Garage', 1);
9+
10+
INSERT INTO categories (id, name) VALUES (1, 'Electronics');
11+
INSERT INTO categories (id, name) VALUES (2, 'Furniture');
12+
INSERT INTO categories (id, name) VALUES (3, 'Appliances');
13+
INSERT INTO categories (id, name) VALUES (4, 'Tools');
14+
INSERT INTO categories (id, name) VALUES (5, 'Jewelry');
15+
16+
INSERT INTO items (id, name, category_id, room_id, brand, model, serial_number, purchase_date, purchase_price, current_value, warranty_expires, notes) VALUES (1, 'Television', 1, 1, 'Sony', 'KD-55X80K', 'SN12345678', '2024-03-15', 799.99, 600.00, '2027-03-15', '55 inch 4K');
17+
INSERT INTO items (id, name, category_id, room_id, brand, model, serial_number, purchase_date, purchase_price, current_value, warranty_expires, notes) VALUES (2, 'Sofa', 2, 1, 'Ashley', 'Darcy', NULL, '2023-06-01', 549.00, 400.00, NULL, 'Gray fabric');
18+
INSERT INTO items (id, name, category_id, room_id, brand, model, serial_number, purchase_date, purchase_price, current_value, warranty_expires, notes) VALUES (3, 'Refrigerator', 3, 2, 'LG', 'LRMVS3006S', 'RF98765432', '2022-11-20', 2499.00, 1800.00, '2025-11-20', 'French door');
19+
INSERT INTO items (id, name, category_id, room_id, brand, model, serial_number, purchase_date, purchase_price, current_value, warranty_expires, notes) VALUES (4, 'Microwave', 3, 2, 'Panasonic', 'NN-SN686S', NULL, '2024-01-10', 149.99, 120.00, '2025-01-10', '1200W');
20+
INSERT INTO items (id, name, category_id, room_id, brand, model, serial_number, purchase_date, purchase_price, current_value, warranty_expires, notes) VALUES (5, 'Bed Frame', 2, 3, 'Zinus', 'SmartBase', NULL, '2023-08-15', 189.00, 150.00, NULL, 'Queen size');
21+
INSERT INTO items (id, name, category_id, room_id, brand, model, serial_number, purchase_date, purchase_price, current_value, warranty_expires, notes) VALUES (6, 'Laptop', 1, 4, 'Dell', 'XPS 15', 'DL55667788', '2024-06-01', 1599.00, 1300.00, '2027-06-01', '32GB RAM');
22+
INSERT INTO items (id, name, category_id, room_id, brand, model, serial_number, purchase_date, purchase_price, current_value, warranty_expires, notes) VALUES (7, 'Monitor', 1, 4, 'Dell', 'U2722D', 'MN11223344', '2024-06-01', 449.99, 380.00, '2027-06-01', '27 inch');
23+
INSERT INTO items (id, name, category_id, room_id, brand, model, serial_number, purchase_date, purchase_price, current_value, warranty_expires, notes) VALUES (8, 'Drill', 4, 5, 'DeWalt', 'DCD771C2', NULL, '2023-04-20', 99.00, 70.00, NULL, 'Cordless');
24+
INSERT INTO items (id, name, category_id, room_id, brand, model, serial_number, purchase_date, purchase_price, current_value, warranty_expires, notes) VALUES (9, 'Table Saw', 4, 5, 'DeWalt', 'DWE7485', 'TS99887766', '2022-09-10', 349.00, 250.00, '2025-09-10', '10 inch');
25+
INSERT INTO items (id, name, category_id, room_id, brand, model, serial_number, purchase_date, purchase_price, current_value, warranty_expires, notes) VALUES (10, 'Wedding Ring', 5, 3, 'Tiffany', NULL, NULL, '2015-06-20', 3500.00, 4000.00, NULL, 'Platinum band');
26+
27+
INSERT INTO photos (id, item_id, filename, description) VALUES (1, 1, 'tv_front.jpg', 'Front view');
28+
INSERT INTO photos (id, item_id, filename, description) VALUES (2, 1, 'tv_serial.jpg', 'Serial number label');
29+
INSERT INTO photos (id, item_id, filename, description) VALUES (3, 6, 'laptop.jpg', 'Laptop with accessories');
30+
INSERT INTO photos (id, item_id, filename, description) VALUES (4, 10, 'ring.jpg', 'Wedding ring close-up');

examples/inventory/schema.sql

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
-- Home Inventory Schema
2+
-- SQLite/CE Example
3+
4+
CREATE TABLE rooms (
5+
id INTEGER PRIMARY KEY,
6+
name TEXT NOT NULL,
7+
floor INTEGER
8+
);
9+
10+
CREATE TABLE categories (
11+
id INTEGER PRIMARY KEY,
12+
name TEXT NOT NULL
13+
);
14+
15+
CREATE TABLE items (
16+
id INTEGER PRIMARY KEY,
17+
name TEXT NOT NULL,
18+
category_id INTEGER,
19+
room_id INTEGER,
20+
brand TEXT,
21+
model TEXT,
22+
serial_number TEXT,
23+
purchase_date TEXT,
24+
purchase_price REAL,
25+
current_value REAL,
26+
warranty_expires TEXT,
27+
notes TEXT
28+
);
29+
30+
CREATE TABLE photos (
31+
id INTEGER PRIMARY KEY,
32+
item_id INTEGER NOT NULL,
33+
filename TEXT NOT NULL,
34+
description TEXT
35+
);
36+
37+
CREATE INDEX idx_items_room ON items(room_id);
38+
CREATE INDEX idx_items_category ON items(category_id);
39+
CREATE INDEX idx_photos_item ON photos(item_id);
40+
41+
-- Views
42+
CREATE VIEW v_items AS
43+
SELECT i.id, i.name, c.name AS category, r.name AS room,
44+
i.brand, i.model, i.purchase_price, i.current_value
45+
FROM items i
46+
LEFT JOIN categories c ON i.category_id = c.id
47+
LEFT JOIN rooms r ON i.room_id = r.id;
48+
49+
CREATE VIEW v_room_totals AS
50+
SELECT r.name AS room, COUNT(i.id) AS item_count,
51+
SUM(i.current_value) AS total_value
52+
FROM rooms r
53+
LEFT JOIN items i ON r.id = i.room_id
54+
GROUP BY r.id;
55+
56+
CREATE VIEW v_warranty_expiring AS
57+
SELECT name, brand, model, warranty_expires
58+
FROM items
59+
WHERE warranty_expires IS NOT NULL
60+
AND warranty_expires <= date('now', '+6 months');

examples/library/queries.sql

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
-- Home Library Example Queries
2+
-- SQLite/CE Example
3+
4+
-- List all books with author names
5+
SELECT b.title, a.name AS author, b.year_published, b.genre
6+
FROM books b
7+
LEFT JOIN authors a ON b.author_id = a.id
8+
ORDER BY a.name, b.title;
9+
10+
-- Books by genre
11+
SELECT genre, COUNT(*) AS count
12+
FROM books
13+
GROUP BY genre
14+
ORDER BY count DESC;
15+
16+
-- Currently loaned books
17+
SELECT b.title, l.borrower, l.date_out, l.date_due
18+
FROM loans l
19+
JOIN books b ON l.book_id = b.id
20+
WHERE l.date_returned IS NULL;
21+
22+
-- Overdue books (assuming today is 2026-01-10)
23+
SELECT b.title, l.borrower, l.date_due
24+
FROM loans l
25+
JOIN books b ON l.book_id = b.id
26+
WHERE l.date_returned IS NULL
27+
AND l.date_due < '2026-01-10';
28+
29+
-- Top rated books
30+
SELECT title, rating
31+
FROM books
32+
WHERE rating = 5;
33+
34+
-- Books added this year
35+
SELECT title, date_added
36+
FROM books
37+
WHERE date_added >= '2025-01-01'
38+
ORDER BY date_added;
39+
40+
41+
-- Using views
42+
SELECT * FROM v_books ORDER BY author, title;
43+
44+
SELECT * FROM v_loans_active;

examples/library/sample_data.sql

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
-- Home Library Sample Data
2+
-- SQLite/CE Example
3+
4+
INSERT INTO authors (id, name, birth_year) VALUES (1, 'Donald Knuth', 1938);
5+
INSERT INTO authors (id, name, birth_year) VALUES (2, 'Brian Kernighan', 1942);
6+
INSERT INTO authors (id, name, birth_year) VALUES (3, 'Andrew Tanenbaum', 1944);
7+
INSERT INTO authors (id, name, birth_year) VALUES (4, 'Charles Petzold', 1953);
8+
INSERT INTO authors (id, name, birth_year) VALUES (5, 'Steve McConnell', 1962);
9+
INSERT INTO authors (id, name, birth_year) VALUES (6, 'Douglas Boling', NULL);
10+
INSERT INTO authors (id, name, birth_year) VALUES (7, 'John Murray', NULL);
11+
INSERT INTO authors (id, name, birth_year) VALUES (8, 'Dominic Selly', NULL);
12+
INSERT INTO authors (id, name, birth_year) VALUES (9, 'David Patterson', 1947);
13+
INSERT INTO authors (id, name, birth_year) VALUES (10, 'John Hennessy', 1952);
14+
INSERT INTO authors (id, name, birth_year) VALUES (11, 'Joseph Yiu', NULL);
15+
16+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (1, 'The Art of Computer Programming Vol 1', 1, '0201896834', 1968, 'Computer Science', 'Hardcover', 'Shelf A1', 5, '2025-01-15');
17+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (2, 'The Art of Computer Programming Vol 2', 1, '0201896842', 1969, 'Computer Science', 'Hardcover', 'Shelf A1', 5, '2025-01-15');
18+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (3, 'The Art of Computer Programming Vol 3', 1, '0201896850', 1973, 'Computer Science', 'Hardcover', 'Shelf A1', 5, '2025-01-15');
19+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (4, 'The C Programming Language', 2, '0131103628', 1978, 'Programming', 'Paperback', 'Shelf A2', 5, '2025-02-10');
20+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (5, 'The Practice of Programming', 2, '020161586X', 1999, 'Programming', 'Paperback', 'Shelf A2', 5, '2025-02-10');
21+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (6, 'Operating Systems: Design and Implementation', 3, '0136386776', 1987, 'Operating Systems', 'Hardcover', 'Shelf B1', 5, '2025-03-01');
22+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (7, 'Programming Windows', 4, '157231995X', 1998, 'Programming', 'Hardcover', 'Shelf B2', 5, '2025-04-20');
23+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (8, 'Code: The Hidden Language', 4, '0735611319', 1999, 'Computer Science', 'Paperback', 'Shelf B2', 5, '2025-04-20');
24+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (9, 'Code Complete', 5, '0735619670', 1993, 'Software Engineering', 'Paperback', 'Shelf C1', 5, '2025-05-05');
25+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (10, 'Programming Windows CE', 6, '1572318562', 1998, 'Windows CE', 'Hardcover', 'Shelf D1', 5, '2025-06-01');
26+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (11, 'Programming Microsoft Windows CE .NET', 6, '0735618844', 2003, 'Windows CE', 'Hardcover', 'Shelf D1', 5, '2025-06-01');
27+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (12, 'Windows CE 3.0 Application Programming', 7, '0130255920', 2000, 'Windows CE', 'Paperback', 'Shelf D1', 4, '2025-06-15');
28+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (13, 'Pocket PC Developers Guide', 8, '0072132302', 2001, 'Windows CE', 'Paperback', 'Shelf D2', 4, '2025-06-15');
29+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (14, 'Computer Organization and Design', 9, '1558604286', 1994, 'Computer Architecture', 'Hardcover', 'Shelf E1', 5, '2025-07-01');
30+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (15, 'Computer Architecture: A Quantitative Approach', 10, '1558605967', 1990, 'Computer Architecture', 'Hardcover', 'Shelf E1', 5, '2025-07-01');
31+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (16, 'The Definitive Guide to ARM Cortex-M0', 11, '0123854776', 2011, 'Embedded Systems', 'Paperback', 'Shelf E2', 4, '2025-08-01');
32+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (17, 'See MIPS Run', NULL, '1558604103', 1999, 'Embedded Systems', 'Paperback', 'Shelf E2', 5, '2025-08-15');
33+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (18, 'SH3/SH4 Programming Manual', NULL, NULL, 1998, 'Embedded Systems', 'Paperback', 'Shelf E3', 4, '2025-09-01');
34+
INSERT INTO books (id, title, author_id, isbn, year_published, genre, format, location, rating, date_added) VALUES (19, 'StrongARM System Developers Guide', NULL, '0126256209', 2000, 'Embedded Systems', 'Hardcover', 'Shelf E3', 4, '2025-09-01');
35+
36+
INSERT INTO loans (id, book_id, borrower, date_out, date_due, date_returned) VALUES (1, 2, 'Alice Chen', '2025-11-01', '2025-12-01', '2025-11-20');
37+
INSERT INTO loans (id, book_id, borrower, date_out, date_due, date_returned) VALUES (2, 8, 'Bob Martinez', '2025-12-15', '2026-01-15', NULL);
38+
INSERT INTO loans (id, book_id, borrower, date_out, date_due, date_returned) VALUES (3, 15, 'Carol Singh', '2026-01-05', '2026-02-05', NULL);

examples/library/schema.sql

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
-- Home Library Catalog Schema
2+
-- SQLite/CE Example
3+
4+
CREATE TABLE authors (
5+
id INTEGER PRIMARY KEY,
6+
name TEXT NOT NULL,
7+
birth_year INTEGER
8+
);
9+
10+
CREATE TABLE books (
11+
id INTEGER PRIMARY KEY,
12+
title TEXT NOT NULL,
13+
author_id INTEGER,
14+
isbn TEXT,
15+
year_published INTEGER,
16+
genre TEXT,
17+
format TEXT,
18+
location TEXT,
19+
rating INTEGER,
20+
date_added TEXT,
21+
notes TEXT
22+
);
23+
24+
CREATE TABLE loans (
25+
id INTEGER PRIMARY KEY,
26+
book_id INTEGER NOT NULL,
27+
borrower TEXT NOT NULL,
28+
date_out TEXT NOT NULL,
29+
date_due TEXT,
30+
date_returned TEXT
31+
);
32+
33+
CREATE INDEX idx_books_author ON books(author_id);
34+
CREATE INDEX idx_books_genre ON books(genre);
35+
CREATE INDEX idx_loans_book ON loans(book_id);
36+
37+
-- Views
38+
CREATE VIEW v_books AS
39+
SELECT b.id, b.title, a.name AS author, b.year_published,
40+
b.genre, b.format, b.location, b.rating
41+
FROM books b
42+
LEFT JOIN authors a ON b.author_id = a.id;
43+
44+
CREATE VIEW v_loans_active AS
45+
SELECT l.id, b.title, l.borrower, l.date_out, l.date_due
46+
FROM loans l
47+
JOIN books b ON l.book_id = b.id
48+
WHERE l.date_returned IS NULL;

media/intro.png

13 KB
Loading

0 commit comments

Comments
 (0)