Crypto wrappers
Project description
ZCrypto Wrapper
ZPy Database Core
Zurck'z Py
This package contains some helpers features for encrypt data .
ZPy use the following packages:
- pycrypto
Requirements
- Python 3.6+
Installation
Use the package manager pip to install py flask micro service core .
pip install zpy
pip install package_directory directory_to_install
Features
Contains some helper features with specific integrations.
- Database
- Only MySQL implementation
- Functions executor
- Stored Procedures executor
- Autocommit is false by default
- Only MySQL implementation
- Utils
- funcs
Roadmap
- ActiveRecord implementation
- Cluster
Basic Usage
Basic Configuration
config = {
"user": "",
"password": "",
"database": "",
"host": "",
"port": 3306
}
With single datasource
# Create database mediator with single datasource
db_manager = ZMediator.single(config, True)
# Open connection
db_conn = db_manager.default().new_connect()
try:
# Execute function
res = db_manager.default().exec("FN_GET_USER_BY_ID(%d)", list_params=[1], ret_type=DBTypes.cursor)
print(res)
except Exception as e:
logging.exception(e)
finally:
# ⚠ Remember close opened connection
db_conn.close()
Multiple Datasources
# Define db mediator
# Setup base configuration in ZMediator()
# The base configuration will be overwritten by add common values
db_mngr = ZMediator(config, False)
.add_common("DB_NAME_1", "DB_USER", "DB_PASSWORD", True) # Mark default ds
.add_common("DB_NAME_2", "DB_USER", "DB_PASSWORD")
.add_common("DB_NAME_3", "DB_USER", "DB_PASSWORD")
db_conn1 = db_mngr.default().new_connect()
db_conn2 = db_mngr.get("DB_NAME_1").new_connect()
db_conn3 = db_mngr.get("DB_NAME_3").new_connect()
try:
# Execute function
res = db_mngr.default().exec("FN_GET_USER_BY_ID(%d)", list_params=[1], ret_type=DBTypes.cursor)
print(res)
# Execute function
res = db_mngr.get("DB_NAME_2").exec("FN_GET_USER_BY_ID(%d)", list_params=[1], ret_type=DBTypes.cursor)
print(res)
# Call sp
res = db_mngr.get("DB_NAME_3").call("SP_GET_DATA", ret_type=DBTypes.cursor)
print(res)
except Exception as e:
logging.exception(e)
finally:
# ⚠ Remember close opened connections
db_conn1.close()
db_conn2.close()
db_conn3.close()
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Authors
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
Built Distribution
Close
Hashes for zpy_ciphers_utils-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 984b1a35a37899bb4eeb1427026344464489bbc5355355e3d6207248c2700e70 |
|
MD5 | 4c74927dc6a9be8d491c0000d4e9882b |
|
BLAKE2b-256 | dc424d6fbf5ae47d3da509ea50d49247cbfbb6f2b13a3073bb715dd6cb645b67 |