Skip to main content

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)dict
  • execute(sql, params) — INSERT / UPDATE / DELETE
  • print_table(sql, params) — prints formatted table to terminal

Formatter

  • print_table(rows) — print list of dicts as ASCII table
  • to_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-5.0.0.tar.gz (133.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymysql_term-5.0.0-py3-none-any.whl (160.2 kB view details)

Uploaded Python 3

File details

Details for the file pymysql_term-5.0.0.tar.gz.

File metadata

  • Download URL: pymysql_term-5.0.0.tar.gz
  • Upload date:
  • Size: 133.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pymysql_term-5.0.0.tar.gz
Algorithm Hash digest
SHA256 a43c4a0952f464cbc3034116f330f0262c292832750d0762e5d3ec96abed2e97
MD5 3d996485d9de046da0a70832acc08d3c
BLAKE2b-256 dcc87c024738c1e772d3b3d93501d1c2482054869c26b5e7313ffb7fd721b9ac

See more details on using hashes here.

File details

Details for the file pymysql_term-5.0.0-py3-none-any.whl.

File metadata

  • Download URL: pymysql_term-5.0.0-py3-none-any.whl
  • Upload date:
  • Size: 160.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pymysql_term-5.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c9b5c4d7630903e5fabecfd0490983099408df75e1d4f1f58aa067b66641130
MD5 65eb9b8ab5c3455b315b59f93ea7602f
BLAKE2b-256 9b2618b21d68bf7abf3001b21ee00a6b308f70182773e00a2e0d3f5ebce88211

See more details on using hashes here.

Supported by

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