A Query Builder
- FIXME
Terms defined: active record, Build manager
FIXME: create query builder
- SQL requires parts of query in an odd order
- So create active records using the Builder pattern
- Does not scale up to more complex queries
- Have to build an expression tree in memory and rearrange clauses for that
- Thanks to Mike Bayer for advice
select_all.py
: get all rows of table using reflection to get table nameget_metadata.py
: cache table description and convert row tuples to dictionariessimpler_metadata.py
: let SQLite do thatchoose_columns.py
: select columns using immediate string formatting- test get-all case as well as getting specific columns
- exercise: re-introduce cached metadata to do error handling
delay_columns.py
: havequery
save the column names for later use inrun
method- complicates things now, but becomes useful later
aggregate.py
: add aggregation- columns can now be string or aggregates
- exercise: add group-by
insert.py
: insert values- go back to keeping metadata in class (which may add startup overheads for large programs)
- exercise: handle insertion of multiple records
- exercise: handle insertion of objects with appropriately-named fields