Amazon Redshift¶
Warning
From version 5 the package psycopg2-binary`
will not be installed by default anymore.
Please make sure to include extras redshift
in your requirements.txt file, see below.
Installation¶
Use extras redshift to install all required packages.
$ pip install mara-db[redshift]
The psql
client is required which can be installed on Ubuntu/Debian via
$ sudo apt-get install postgresql-client
To read from STDIN an additional S3 bucket is required as temp storage. You need to install the awscli package in addition:
$ pip install awscli
Configuration examples¶
import mara_db.dbs
mara_db.config.databases = lambda: {
'dwh': mara_db.dbs.RedshiftDB(
host='localhost',
user='root',
password='<my_strong_password>',
database='dwh'),
}
import mara_db.dbs
mara_db.config.databases = lambda: {
'dwh': mara_db.dbs.RedshiftDB(
host='localhost',
user='root',
password='<my_strong_password>',
database='dwh',
aws_access_key_id='...,
aws_secret_access_key='...',
=aws_s3_bucket_name='my-s3-bucket'),
}
API reference¶
This section contains database specific API in the module.
Configuration¶
- class mara_db.dbs.RedshiftDB(host: Optional[str] = None, port: Optional[int] = None, database: Optional[str] = None, user: Optional[str] = None, password: Optional[str] = None, aws_access_key_id=None, aws_secret_access_key=None, aws_s3_bucket_name=None)¶
- __init__(host: Optional[str] = None, port: Optional[int] = None, database: Optional[str] = None, user: Optional[str] = None, password: Optional[str] = None, aws_access_key_id=None, aws_secret_access_key=None, aws_s3_bucket_name=None)¶
Connection information for a RedShift database
The aws_* parameters are for copying to Redshift from stdin via an s3 bucket (requires the https://pypi.org/project/awscli/) package to be installed)
- property sqlalchemy_url¶
Returns the SQLAlchemy url for a database