sqlite_get_list_from_table¶
Useful tools for reading sqlite database tables into Python data structures. Each row of your database table is converted into a namedtuple with fieldnames taken from the sqlite table definition. Using the namedtuple._asdict() method allows you to use treat each table as a list of dicts or if your table has a primary key which is unique for each row in the table, as a dict of dicts.
get_list_from_table() + get_dict_from_table() is 12 lines because of the useful uniqueness test in the dict routine and because doing camelize() inline would make the code too difficult to understand.
Attributes¶
Functions¶
|
convert an sqlite database table into a list of namedtuples. |
|
convert an sqlite database table into a dict of namedtuples |
Module Contents¶
- sqlite_get_list_from_table.db_filename = 'my.db'¶
- sqlite_get_list_from_table.get_list_from_table(sqlite_connection, table_name)¶
convert an sqlite database table into a list of namedtuples.
- sqlite_get_list_from_table.get_dict_from_table(sqlite_connection, table_name, key_col_name='id')¶
convert an sqlite database table into a dict of namedtuples useful for tables where each row has a unique primary key.
- sqlite_get_list_from_table.get_services()¶
- sqlite_get_list_from_table.get_employee_dict()¶
- sqlite_get_list_from_table.services¶
- sqlite_get_list_from_table.employee_dict¶