PostgreSQL¶
PostgreSQL is the main database engines which is currently installed by default.
Warning
From version 5 the requirements for PostgreSQL will not be installed by default anymore.
Please make sure to include extras postgres
in your requirements.txt file, see below.
Installation¶
Use extras postgres to install all required packages.
$ pip install mara-db[postgres]
The psql
client is required which can be installed on Ubuntu/Debian via
$ sudo apt-get install postgresql-client
Configuration examples¶
import mara_db.dbs
mara_db.config.databases = lambda: {
'dwh': mara_db.dbs.PostgreSQLDB(
host='localhost',
user='root',
database='dwh'),
}
import mara_db.dbs
mara_db.config.databases = lambda: {
'dwh': mara_db.dbs.PostgreSQLDB(
host='localhost',
user='root',
password='<my_strong_password>',
database='dwh'),
}
API reference¶
This section contains database specific API in the module.
Configuration¶
- class mara_db.dbs.PostgreSQLDB(host: Optional[str] = None, port: Optional[int] = None, database: Optional[str] = None, user: Optional[str] = None, password: Optional[str] = None, sslmode: Optional[str] = None, sslrootcert: Optional[str] = None, sslcert: Optional[str] = None, sslkey: Optional[str] = None)¶
- __init__(host: Optional[str] = None, port: Optional[int] = None, database: Optional[str] = None, user: Optional[str] = None, password: Optional[str] = None, sslmode: Optional[str] = None, sslrootcert: Optional[str] = None, sslcert: Optional[str] = None, sslkey: Optional[str] = None)¶
Connection information for a PostgreSQL database
For the SSL options, see https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-PROTECTION
- property sqlalchemy_url¶
Returns the SQLAlchemy url for a database