dicogis.models.database_connection module

Model for database connection.

class dicogis.models.database_connection.DatabaseConnection(name=None, database_name=None, host=None, port=None, service_name=None, user_name=None, user_password=None, is_esri_sde=False, is_postgis=True, sgbd_schemas=None, sgbd_version=None, state_msg=None)

Bases: object

Database connection abstraction model.

__init__(name=None, database_name=None, host=None, port=None, service_name=None, user_name=None, user_password=None, is_esri_sde=False, is_postgis=True, sgbd_schemas=None, sgbd_version=None, state_msg=None)
property connection_params_as_dict: dict | None
Return connection parameters as dictionary. Useful to create a service in a

pg_service.conf file.

Returns:

connection parameters as dict

database_name: Optional[str] = None
host: Optional[str] = None
is_esri_sde: bool = False
is_postgis: bool = True
name: Optional[str] = None
property pg_connection_string: str

Get PostgreSQL connection string.

See: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING. Structure: host=localhost port=5432 dbname=mydb connect_timeout=10

Returns:

Connection string for PostgreSQL

Return type:

str

property pg_connection_uri: str

Get PostgreSQL connection URI.

See: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING. Structure: postgresql://[userspec@][hostspec][/dbname][?paramspec]

Returns:

Connection URI for PostgreSQL

Return type:

str

port: Optional[int] = None
service_name: Optional[str] = None
sgbd_schemas: Optional[set[str]] = None
sgbd_version: Optional[str] = None
state_msg: Optional[str] = None
store_in_pgservice_file()
Store database connection to service file (typically on Linux

~/.pg_service.conf).

Return type:

tuple[bool, str]

Returns:

a tuple with the store status and a log message

user_name: Optional[str] = None
user_password: Optional[str] = None