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-2.0.0.tar.gz
(3.9 kB
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-2.0.0.tar.gz.
File metadata
- Download URL: pymysql_term-2.0.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e05648fcd19a2722f100545fc90aac82c9c4e23d18fd8e04351794ba13d40119
|
|
| MD5 |
5b9af4e71f7f28f7ff5ae22fa870f300
|
|
| BLAKE2b-256 |
a7d6a14cbd94b1713360daa6b9a7d70ef2a9589d414dcc5385ad7e938f67d03b
|
File details
Details for the file pymysql_term-2.0.0-py3-none-any.whl.
File metadata
- Download URL: pymysql_term-2.0.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10e8c2197157498b16724e6eb68b6f9d7778116a219087e0a36b2254789629f8
|
|
| MD5 |
dff49037428180d3847c5e1f27fc0d62
|
|
| BLAKE2b-256 |
05faca1e1dca6311039921ed9c726cf05b1f4976a9daaeebba727c383a1a26e0
|