Package: xplordb
xplordbMineral Exploration Database template/ system for Postgres/PostGIS and QGIS.The project incorporates import scripts, data storage, validation, reporting, 3D drill trace generation and more. psql, pgAdmin and QGIS are the suggested database and GIS front-end programs.The xplordb database template also comes with a pythonxplordbpackage.Installationxplordbpackage can be installed with pip :pip install xplordbInstall xplordb schemafromxplordb.import_ddlimportImportDDLimport_ddl=ImportDDL(db='xplordb',user='postgres',password='postgres',host='localhost',port=5432)import_ddl.import_xplordb_schema(import_data=False,full_db=False)xplordb schema installation can only be done on existing databaseCreate xplordb databasefromxplordb.create_dbimportCreateDatabasecreate_db=CreateDatabase(connection_db='postgres',user='postgres',password='postgres',host='localhost',port=5432)create_db.create_db(db='xplordb',import_data=False,full_db=False)connection database is needed for new database creationAvailable options are :import_data: Import sample datafull_db: Import not mandatory tablesxplordb APIWith xplordb package you can data to an xplordb database.Here are some examples of API use.Create mandatory Person and Datasetfromxplordb.sqlalchemy.baseimportcreate_sessionfromxplordb.datamodel.personimportPersonfromxplordb.datamodel.datasetimportDatasetfromxplordb.import_dataimportImportDatasession=create_session(database='xplordb',host='localhost',port=5432,user='postgres',password='postgres')import_data=ImportData(session)import_data.import_persons_array([Person(trigram="xdb",full_name="default")])import_data.import_datasets_array([Dataset(name="default",loaded_by="xdb")])session.commit()Create a collarfromxplordb.sqlalchemy.baseimportcreate_sessionfromxplordb.datamodel.collarimportCollarfromxplordb.import_dataimportImportDatasession=create_session(database='xplordb',host='localhost',port=5432,user='postgres',password='postgres')import_data=ImportData(session)import_data.import_collars_array([Collar(hole_id="collar",data_set='default',loaded_by='xdb',x=100.0,y=100.0,z=0.0,srid=3857)])session.commit()We assume that person and dataset are already available in xplordb databaseAdd survey to collarfromxplordb.sqlalchemy.baseimportcreate_sessionfromxplordb.datamodel.surveyimportSurveyfromxplordb.import_dataimportImportDatasession=create_session(database='xplordb',host='localhost',port=5432,user='postgres',password='postgres')import_data=ImportData(session)import_data.import_surveys_array([Survey('collar','default','xdb',dip=0.0,azimuth=45.0,depth=0.0),Survey('collar','default','xdb',dip=0.1,azimuth=44.5,depth=100.0),Survey('collar','default','xdb',dip=0.0,azimuth=45.0,depth=200.0)])session.commit()We assume that person dataset and collar are already available in xplordb databaseUse sqlalchemy session for new queryxplordbmodule provides sqlalchemy table description that can be used to interact with xplordb database without usingImportDataclass :ref.person:xplordb.sqlalchemy.ref.person.XplordbPersonTableref.dataset:xplordb.sqlalchemy.ref.dataset.XplordbDatasetTabledh.collar:xplordb.sqlalchemy.dh.collar.XplordbCollarTabledh.survey:xplordb.sqlalchemy.dh.survey.XplordbSurveyTableref.lithology:xplordb.sqlalchemy.ref.lithcode.XplordbLithCodeTabledf.lith:xplordb.sqlalchemy.df.lith.XplordbLithTableExample to get all survey for a collar list:fromxplordb.sqlalchemy.baseimportcreate_sessionfromxplordb.sqlalchemy.dh.surveyimportXplordbSurveyTablesession=create_session(database='xplordb',host='localhost',port=5432,user='postgres',password='postgres')collars_id=['HOLE_1','HOLE_2']surveys=session.query(XplordbSurveyTable).filter(XplordbSurveyTable.hole_id.in_(collars_id)).all()