Basic project utilities
Project description
This project joins some useful scripts designed to speed up project development.
Main scripts are:
configuration.py
Configuration load from different sources:
AWS Systems manager parameter store
configuration = load_config('ssm',environment)
SSM variable key must have format: /$environment/$section and value in json format
Key | Value |
---|---|
/pre/ddbb | {"host":"localhost","port":3306,"username":"root","password":"changeit"} |
Local file
configuration = load_config('file',environment, file_name)
File expected in standard INI file structure.
[ddbb]
host=localhost
port=3306
username=root
password=changeit
Environment variables.
configuration = load_config('env',environment, projectname)
Variables should have the following format: $projectname_$environemnt_$sectionname
MYPROJECT_PRO_DDBB_HOST=localhost
MYPROJECT_PRO_DDBB_PORT=3306
MYPROJECT_PRO_DDBB_USERNAME=root
MYPROJECT_PRO_DDBB_PASSWORD=changeit
database.py
Database connection and query execution
database = database(configuration)
To execute query, use method Database.run_query
records = database.run_query('SELECT * FROM table WHERE mycolumn = %s AND myothercolumn = '%s',('value1', 'value2' ))
Pagination is supported using class database.Page:
page_number = 1
page_size = 50
page = database.Page(page_number, page_size)
records = database.run_query('SELECT * FROM table WHERE mycolumn = %s AND myothercolumn = '%s', ('value1', 'value2' ), page)
alerts.py
Alert sending, via AWS simple email service.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
basacommons-0.0.11.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for basacommons-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3083ac20a176006af0f140846b15949cc1c8055de7c895af8ffdeb8796bd3747 |
|
MD5 | b19a74229b53c07b70b9c9e8f03d08b8 |
|
BLAKE2b-256 | f6f2457314dc16f980d10d274aa9c23289b15650d2b3b25efa33be97c0747bb6 |