geoslurp.db package

Submodules

geoslurp.db.connector module

class geoslurp.db.connector.GeoslurpConnector(host, user, passwd=None, port=5432, dataroot=None, cache=None)

Bases: GeoslurpConnectorBase

Holds a connector to a geoslurp database

CreateSchema(schema, private=False)
addUser(name, passw, readonly=False)

Adds a user to the database (note executing this functions requires appropriate database rights

createTable(tablename, columns, schema=None, temporary=False, truncate=False, bind=None)

Creates a (temporary) table from sqlalchemy columns and returns the corresponding tablemapper

createView(viewname, qry, schema=None)
dropSchema(schema, cascade=False)
dropTable(tablename, schema=None)
dropView(viewname, schema=None)
execute(qry)
getFunc(fname, schema='public')

returns a database function based up string names

getTable(tname, schema='public', customcolumns=None)
schemaexists(name)
tableExists(tablename)
transsession()

Retrieve a session which is bound to a connection rather than an engine (e.g. useful for temporary tables)

truncateTable(tablename, schema=None)
vacuumAnalyze(tableName, schema)

vacuum and analyze a certain table

geoslurp.db.connector.tname(tablename, schema=None)

Create a fully qualified database name in lower case from a schema and tablename

geoslurp.db.connectorbase module

class geoslurp.db.connectorbase.GeoslurpConnectorBase(cache=None, dataroot=None)

Bases: object

Holds the base class for a connector to a geoslurp database

CreateSchema(schema, private=False)
addUser(name, passw, readonly=False)

Adds a user to the database (note executing this functions requires appropriate database rights

cache = None
createTable(tablename, columns, schema=None, temporary=False, truncate=False, bind=None)

Creates a (temporary) table from sqlalchemy columns and returns the corresponding tablemapper

createView(viewname, qry, schema=None)
dropSchema(schema, cascade=False)
dropTable(tablename, schema=None)
dropView(viewname, schema=None)
getFunc(fname, schema='public')

returns a database function based up string names

getTable(tname, schema='public')
localdataroot = None
schemaexists(name)
transsession()
truncateTable(tablename, schema=None)
vacuumAnalyze(tableName, schema)

vacuum and analyze a certain table

geoslurp.db.connectorbase.raiseNotImpl()

geoslurp.db.exporter module

class geoslurp.db.exporter.MirrorMap(from_mirror, to_mirror)

Bases: object

apply(url)
reverseApply(url)
strip(url)
geoslurp.db.exporter.exportGeoQuery(qryresult, outputfile, layer=None, driver='GPKG', packFiles=False, striproot=None)
geoslurp.db.exporter.exportGeoTable(table, outfile, addFiles=False)

Export a entire table with a geometry column

geoslurp.db.exporter.exportQuery(qryresult, outputfile, layer=None, driver='SQLITE', packUriCols=[], striproot=None, localdataroot=None)

Export a query without a geometry column, and possibly pack corresponding files

geoslurp.db.exporter.exportTable(table, outfile, addFiles=False)

Export a entire table without a geometry column

geoslurp.db.exporter.writeToSQLite(outputfile, df, layer)

Write a pandas dataframe as a table to a sqlite file

geoslurp.db.geoslurpdb module

geoslurp.db.geoslurpdb.geoslurpConnect(args=None, readonly_user=True, local_settings=None, dbalias=None)

Convenience wrapper to start a connection with a geoslurpdatabase. Returns a database connection while taking use of stored settings from the users configuration file ($HOME/.geoslurp_lastused.yaml). :param args: Class which encapsulates different connection parameters :type args: geoslurp.localsettings.settingsArgs

geoslurp.db.inventory module

class geoslurp.db.inventory.InventTable(**kwargs)

Bases: Base

Defines the GEOSLURP POSTGRESQL inventory table

cache
data
datadir
dataset
id
lastupdate
owner
pgfunc
scheme
updatefreq
version
view
class geoslurp.db.inventory.Inventory(geoslurpConn, ses=None)

Bases: object

Class which provides read/write access to the postgresql inventory table

table

alias of InventTable

geoslurp.db.settings module

class geoslurp.db.settings.Credentials(user, passw, alias, oauthtoken, apikey, url, ftptls, trusted)

Bases: tuple

A named tuple to store authentication credentials

Parameters:
  • user (str) – Username for the service

  • alias (str) – (obligatory) The short name of this service

  • passw (str) – The password associated with the username

  • oauthtoken (str) – An oauth2 token

  • apikey (str) – a API key for webservices

  • url (str) – The root url which is linked to this service

  • ftptls (bool) – Use Explicit ftp over tls for this host and user

  • trusted (bool) – Allow forwarding password and username

alias

Alias for field number 2

apikey

Alias for field number 4

ftptls

Alias for field number 6

oauthtoken

Alias for field number 3

passw

Alias for field number 1

trusted

Alias for field number 7

url

Alias for field number 5

user

Alias for field number 0

class geoslurp.db.settings.Settings(dbconn)

Bases: object

Read and write default and user specific settings to and from the database

authCred(service, qryfields=None)

obtains username credentials for a certain service :param service: name of the service :param qryfields: prompt for input for these fields when service is not present :returns a namedtuple with credentials

decryptAuth()

Decrypt the authenfication credentials as stored in the database

decryptAuthv1()

Decrypt the authenficiation credentials as stored in the database

defaultupdate(indict=None)

Update the default conf dictionary in postgresql settings table

delAuth(key)

Delete an authentication entry by specifying it’s alias

encryptAuth()

Encrypt the authentification credentials to store in the database

static genCypher(salt, password)
generalize_path(url)
getCacheDir(schema, dataset=None, subdirs=None)

Obtain and create a cache directory

getDataDir(schema, dataset=None, subdirs=None)

Retrieves the data Directory, possibly appended with a dataset and subdirs

get_PG_path(url)

Possibly modifies a path so it becomes a path accessible by the Database host itself

get_local_path(url)

possibly prepend the localdataroot root to the path or

getdefaults(key)

returns the default

pgmount = None
setdefault(key, val)
show(hideflag='hide')

Show the loaded user configuration

table

alias of SettingsTable

update(indict=None)

Update the conf dictionary in postgresql settings table

updateAuth(cred: Credentials)

register/update a new set of authentication credentials

class geoslurp.db.settings.SettingsTable(**kwargs)

Bases: Base

Defines the GEOSLURP POSTGRESQL settings table

auth
conf
id
user
geoslurp.db.settings.getCreateDir(returndir)

creates a directory when not existent and return it

geoslurp.db.settings.stripPasswords(d)

geoslurp.db.tabletools module

geoslurp.db.tabletools.tableMapFactory(tableName, table=None)

Dynamically create/retrieve a mapper class from a Table object