This python package is based from python mysql connector
Project description
Welcome to EzSQL!
This python package is based from python mysql connector. It allows you to easily consume MySQL service without doing much of the code.
Features
- Perform Basic Secure prepared MySQL queries
- Perform SELECT queries with your return data format of choice
- Get a JSON formatted result
- Get a List formatted result
- Get results in Tuple
- Supports DB Credentials from Environment Variables
Setting up your credentials
To set your credentials, you can set the following in your environment variable. You may also put it in your .env file
EZSQL_DBUSER=your_user
EZSQL_DBPASS=your_pass
EZSQL_DBHOST=your_host
EZSQL_DBNAME=your_db
Creating a query instance
from ezsql.EzSQL import Query
#query_string is your prepared statement.
query_string = "SELECT * FROM table_a WHERE id = %s"
#query_values is a tuple of values
query_values = (1,)
_ezsql = Query(query_string,query_values)
SELECT That returns tuple
_result = _ezsql.run_select()
print(_result)
outputs
[(1, 'foo', 18)]
SELECT That returns a list
_result = _ezsql.run_select_with_list()
print(_result)
outputs
[1, 'foo', 18]
SELECT That returns a JSON
_result = _ezsql.run_select_with_json()
print(_result)
outputs
[{'id': 1, 'name': 'foo', 'age': 18}]
INSERT
_result = _ezsql.run_insert()
print(_result)
outputs
True
UPDATE
_result = _ezsql.run_update()
print(_result)
outputs
True
DELETE
_result = _ezsql.run_delete()
print(_result)
outputs
True
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for python_ezsql-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bb89cc10faeaeb32ff9adba4aa2e15c6e6d4bbd904556529a364c6e84ed6c41 |
|
MD5 | 0dae6fb814df8b46262ab52dd6e61f1e |
|
BLAKE2b-256 | 75ac734d6dfb710de6b9be44904488fd794ddc1001bcefd19062b18bd1e1274d |