Terminal output formatter and query executor for PyMySQL
Project description
pymysql-terminal
Lightweight wrapper around PyMySQL for executing queries and displaying results in the terminal.
Install
pip install pymysql-term
from source:
pip install git+https://github.com/pymysql-term/pymysql-term.git
Usage
from pymysql_terminal import Connection, Executor
conn = Connection(host="localhost", database="mydb", user="root", password="root")
ex = Executor(conn)
# print query result as a table
ex.print_table("SELECT * FROM products WHERE discount > %s", (10,))
# fetch as list of dicts
rows = ex.fetch("SELECT * FROM orders")
# insert / update / delete
ex.execute("UPDATE products SET price = %s WHERE product_id = %s", (999.0, 1))
conn.close()
API
Connection(host, database, user, password, port, charset)
Connects to MySQL. Supports auto-reconnect.
Executor(connection)
fetch(sql, params)→list[dict]fetch_one(sql, params)→dictexecute(sql, params)— INSERT / UPDATE / DELETEprint_table(sql, params)— prints formatted table to terminal
Formatter
print_table(rows)— print list of dicts as ASCII tableto_csv(rows, delimiter)→str
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
pymysql_term-4.0.0.tar.gz
(38.4 MB
view details)
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 pymysql_term-4.0.0.tar.gz.
File metadata
- Download URL: pymysql_term-4.0.0.tar.gz
- Upload date:
- Size: 38.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23c54982ba85464d81724963d25ecb0a3736f2f48088af53537d598854b7a77d
|
|
| MD5 |
4b2d60b6a31834d0068b27bb703ccc0f
|
|
| BLAKE2b-256 |
b35d707e6696f1da2846347ad30a8fd282f3f537c7fff0dfea02a730e3cd0ab0
|
File details
Details for the file pymysql_term-4.0.0-py3-none-any.whl.
File metadata
- Download URL: pymysql_term-4.0.0-py3-none-any.whl
- Upload date:
- Size: 38.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52acc8f575fd02d3f84eb803d4a007f9a10ca11163a8197343ab08be4ac704eb
|
|
| MD5 |
5972023a06284241f6df9729b75de840
|
|
| BLAKE2b-256 |
43a9d51a5a613b52cf26aa7feead048ee147e4c62eaee435e5b31e7a2f0661f7
|