Database connection (Postgres, Redshift)
Project description
Python Package
db_conn
To use this package is necessary create file on your home ~
"~/access_information.json"
{
"database_name": {
"host": "database-db.host.net",
"user": "user",
"password": "1234",
"database": "database_name",
"port": 5432
},
}
⚠️ Warning ❗️
- Remember, if you put your
access_informationinside of your project, add this file into.gitignoreeven if it is a private project, security first 😉
After that to use in code, you just need to:
# if you do not use path var, it will assume default path as ~/access_information.json, if you want to use another path you can pass this new path
# You should pass the 'database_name' that you put on your access_information
# With path:
path = os.path.expanduser("~/access_information.json")
database_access = get_database_access(path)
db_handler = DatabaseHandler(database_access["database_name"])
###########################################################################
# You should pass the 'database_name' that you put on your access_information
# Without path
database_access = get_database_access()
db_handler = DatabaseHandler(database_access["database_name"])
To use this connection properly
query = """
select
*
from table;
"""
df = pd.DataFrame(db_handler.fetch(query))
After use, you should close connection
db_handler.close()
To create table with time series you can use code below, passing start_date, end_date, timezone and frequency
df_script_dim_table = db_handler.create_dim_date('2020-01-01', '2020-05-06', tz='utc', freq='D')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file db_conn-1.0.5.tar.gz.
File metadata
- Download URL: db_conn-1.0.5.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e88125c1009e4d33bc0a5edf390ae95dc68507ad2bcd6ec2e38a922394e366f5
|
|
| MD5 |
430a90ea66ebfb7eb146c8c0b68c60d5
|
|
| BLAKE2b-256 |
ec7ac8556a660b37e4f5ae737128360c6ebce80d42092f280f229d0bda1ec123
|
File details
Details for the file db_conn-1.0.5-py3-none-any.whl.
File metadata
- Download URL: db_conn-1.0.5-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4607685c6d8b49c258fc9c08898d2b7459e02b09c3fc93d36cafc91af04eb194
|
|
| MD5 |
b564abcfdb8127ac030d4254c2135b84
|
|
| BLAKE2b-256 |
a454c394524efed0b5c3d13f160494c76c2936b0d8be4710fe5218a82b2712db
|