materials_commons.cli.sqltable module

class materials_commons.cli.sqltable.SqlTable(proj_local_path)[source]

Bases: object

Generic code for interacting with one table in a project database

This is a base class. Derived classes must implement:

  • @staticmethod default_print_fmt(): list of tuple, used to format a table

  • @staticmethod tablecolumns(): dict, column name as key, list of table creation args for value

  • @staticmethod tablename(): str, table name in sqlite database


proj_local_path – str, local project path


Connect to sqlite database, creating database and table if necessary

insert_or_replace(record, verbose=False)[source]

Insert or replace individual entries in the table

  • record – dict Record to insert or replace in the database.

  • verbose – bool If True, print status

print_selection(iterable, fmt=None)[source]
print_selection_detail(iterable, fmt=None)[source]

Return table size


Location of a sqlite database to cache project data locally

materials_commons.cli.sqltable.sql_iter(curs, fetchsize=1000)[source]

Iterate over the results of a SELECT statement