GeoDataBase#
Special class to manage outputs-input requests from-into SQL database Editing this module presume that you are aware of what you are doing. The module is a core of geology sub-packages. However the the way the dataBase is arranged can be enhanced and adapted for better convenient or other suitable purposes.
- class watex.geology.database.DBSetting(db_name=None, db_host=None)[source]#
Bases:
objectbuild a datable postgre Sql from dict_app.py simple way to make a transit between two objects One object dict_app to populate DataBase
- Parameters:
**db_name** (str) – name of dataBase
**db_host** (st) – path to database
informations (Hold other additional) –
==================================== (==================== ==============) –
Explanation (Attributes Type) –
==================================== –
connection (connex object DataBase) –
cursor (closeDB close after requests the connection and the) –
==================================== –
=============================================== (==========================) – Methods Explanation
=============================================== –
dataBase (dicT_sqlDB send infos as dictionnary to) –
sql_request (execute req execute a) –
Table (drop_TableDB drop all Tables in sql memory DB or single) –
cursor –
data (commit transfer the data to DataBase. if not the) – will still in the cursor and not in the dataBase
system (print_last_Query print the last operating) –
. (export_req export the request on datasheet like excelsheet) –
=============================================== –
Examples
>>> from watex.geology.database import DBSetting >>> path= os.getcwd() >>> nameofDB='memory.sq3' >>> manDB=DBSetting(db_name=nameofDB, ... db_host=path) ... print(SqlQ.sql_req[-1]) ... manDB.executeReq(SqlQ.sql_req[2]) ... ss=manDB.print_last_Query() ... print(ss) ... manDB.export_req(SqlQ.sql_req[-1], export_type='.csv') ... manDB.dicT_sqlDB(dictTables=Glob.dicoT, visualize_request=False)
- connect_DB(db_host=None, db_name=None)[source]#
Create sqqlite Database
- Parameters:
db_host (str) – DataBase location path
db_name (str) – str , DataBase name
- dicT_sqlDB(dicTables, **kwargs)[source]#
Method to create Table for sqlDataBase . Enter Data to DataBase from dictionnary. Interface objet : Database _Dictionnary to see how dicTable is arranged , may consult dict_app module
- Parameters:
dictTables (*) – Rely on dict_app.py module. it populates the datababse from dictionnay app
- Returns:
req – Execute queries from dict_app
- Return type:
str
Examples
>>> from watex.geology.database import DBSetting >>> mDB=DBSetting (dbname='memory.sq3, ... db_host =os.getcwd()') >>> mDB.dicT_sqlDB(dicTables=Glob.dicoT, ... visualize_request=False) >>> ss=mB.print_last_query() >>> print(ss)
- drop_TableDB(dicTables, drop_table_name=None, drop_all=False)[source]#
Drop the name of table on dataBase or all databases.
- Parameters:
dicTables (*) – application dictionnary. Normally provide from dict_app.py module
drop_table_name (*) – field name of dictionnay (Table Name). The default is None.
drop_all (*) – Must select if you need to drop all table. The default is False.
Note
Raise an exception of errors occurs.
- executeReq(query, param=None)[source]#
Execute request of dataBase with detection of error.
- Parameters:
query (*) – sql_query
param (*) – Default is None .
- Raises:
Layout of the wrong sql queries . –
- Returns:
True or False – TWether the request has been successuful run or not.
- Return type:
int
Examples
>>> from watex.geology.database import DBSetting >>> for keys in Glob.dicoT.keys(): ... reqst='select * from %s'%keys >>> ss=DBSetting(dbname='memory.sq3, db_host =os.getcwd()' ).executeReq(query=reqst) >>> print(ss)
- export_req(query=None, export_type='.csv', **kwargs)[source]#
method to export data from DataBase
- Parameters:
query (*) – Sql requests. You may consult sql_request files. The default is None.
export_type (*) – file extension. if None , it will export on simple file. The default is ‘.csv’.
kwargs (*) – Others parameters.
- Returns:
Print wrong SQL request messages.
- Return type:
None
Example
>>> from watex.geology.database import DBSetting >>> from sqlrequests import SqlQ >>> DBSetting(dbname='memory.sq3, db_host =os.getcwd() ).executeReq(SqlQ.sql_req[2]) >>> ss=manageDB.print_last_Query() >>> print(ss) >>> manageDB.export_req(SqlQ.sql_req[-1], export_type='.csv', )
- class watex.geology.database.GeoDataBase(geo_structure_name=None)[source]#
Bases:
objectCore geological database class.
Currently we do not create the specific pattern for each geostructures. DataBase is built is built following structure or property code definition codef:
`code`, `label`, `__description`,`pattern`, `pat_size`,`pat_density`, `pat_thickness`,`RGBA`, `electrical_props`, `hatch`, `colorMPL`, `FGDC`
- Parameters:
**geo_structure_name** (str) – Name of geological rocks , strata or layer.
seealso:: (..) – FGDC-Digital cartographic Standard for Geological Map Symbolisation.
- codef = ['code', 'label', '__description', 'pattern', 'pat_size', 'pat_density', 'pat_thickness', 'rgb', 'electrical_props', 'hatch', 'colorMPL', 'FGDC']#
- property colorMPL#
return geocolorMPL
- property electrical_props#
return electrical property
- geoDataBase = '/home/docs/checkouts/readthedocs.org/user_builds/watex/checkouts/0.2.3/docs/watex/etc/memory.sq3'#
- property hatch#
- make_pattern_symbol = ['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*', '\\-', '\\+', '\\o', '\\O', '\\.', '\\*']#
- property pattern#
return geopattern
- property rgb#
return georgb