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-terminal
Or from source:
pip install git+https://github.com/amirullahmutalibov/pymysql-terminal.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()
Output example
+------------+--------------+----------+----------+
| product_id | product_name | price | discount |
+------------+--------------+----------+----------+
| 1 | Nike Zoom | 1000.00 | 14.0 |
| 2 | Amir Imba | 984000 | 18.0 |
+------------+--------------+----------+----------+
строк: 2
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
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
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_terminal-1.0.0.tar.gz.
File metadata
- Download URL: pymysql_terminal-1.0.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5fb1845f46e84bae8915ebdcd1eaac361db750ebc5c40d9b2de26016ee7b3cf
|
|
| MD5 |
20007cb9a4560b4d1396da97b81a5d83
|
|
| BLAKE2b-256 |
b7e6cfb77a271c16bef8adf578042241192ed47b89132e7cf932112bbe3c4a8c
|
File details
Details for the file pymysql_terminal-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pymysql_terminal-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.4 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 |
fcc8dea20c03615bde245cee4c6df88fbc2d9e91dff963b766c8ecdd374f2063
|
|
| MD5 |
24e1ef0a7c016cdd6054cafd97647aa4
|
|
| BLAKE2b-256 |
a286639e421c0ad0e7c6a475a6e2952c27fb768cc48297c8ae5b8d3096d71155
|