Source code for pygaps.utilities.sqlite_db_creator
"""Generate the default sqlite database."""importjsonimportpygapsfrompygaps.parsingimportsqliteaspgp_sqlitefrompygaps.utilities.sqlite_db_pragmasimportPRAGMASfrompygaps.utilities.sqlite_utilitiesimportdb_execute_general
[docs]defdb_create(path:str,verbose:bool=False):""" Create the entire database. Parameters ---------- path : str Path where the database is created. verbose : bool Print out extra information. """forpragmainPRAGMAS:db_execute_general(pragma,path,verbose=verbose)# Get json filestry:fromimportlib.resourcesimportfilesasir_filesexceptImportError:# TODO Deprecation after supported Python > 3.8# Use backported `importlib_resources`.fromimportlib_resourcesimportfilesasir_files# Get and upload adsorbate property typesads_props_json=ir_files('pygaps.data').joinpath('adsorbate_props.json').read_text(encoding='utf8')ads_props=json.loads(ads_props_json)forap_typeinads_props:pgp_sqlite.adsorbate_property_type_to_db(ap_type,db_path=path,verbose=verbose)# Get and upload adsorbatesads_json=ir_files('pygaps.data').joinpath('adsorbates.json').read_text(encoding='utf8')adsorbates=json.loads(ads_json)foradsinadsorbates:pgp_sqlite.adsorbate_to_db(pygaps.Adsorbate(**ads),db_path=path,verbose=verbose)# Upload standard isotherm typespgp_sqlite.isotherm_type_to_db({'type':'isotherm'},db_path=path)pgp_sqlite.isotherm_type_to_db({'type':'pointisotherm'},db_path=path)pgp_sqlite.isotherm_type_to_db({'type':'modelisotherm'},db_path=path)