Skip to main content

Crypto wrappers

Project description

Zurck'z

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
  • 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

MIT

Authors

Noé Cruz

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

zpy-ciphers-utils-0.0.1.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

zpy_ciphers_utils-0.0.1-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page