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-3.0.0.tar.gz (16.7 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-3.0.0-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pymysql_term-3.0.0.tar.gz
Algorithm Hash digest
SHA256 d9a789d8e892987e78aad6f7b9c16672dd1d993523ea255911695f558cdca636
MD5 d57f6e44e5fecee5dc0a62d43023ce51
BLAKE2b-256 96a2b21b217e5b47ce4bb533224fe1b0d0c707ac45182a430ed63b6eec1c8a0e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymysql_term-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 25.5 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-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5948087e2f836d84e7eae76120acf327aa05f31c57b28e311709aaa3f0a2ec80
MD5 fb1f0e82aedea21d8d8347fcd0d18bc8
BLAKE2b-256 b4595a08991d6c0720991d1350e434fe2c6f2ae2bdec58a16fed6f1fedc15cc3

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