Skip to main content

xonsh python for pg

Project description

Postgresql Xonsh Python Tools

A bunch of scritps to use postgresql in xonsh. Install as usual

python3 setup.py install --user

Usage

Start xonsh, load the macros in xonshrc. If user not doing anyting, xpg will connection to the default database as default user -- most likely this means $USER.

Notice that we do not use ; to end the query. Just press return and xonsh will handle multiline just fine.

Run a sql

sql! select i, i*2 as j from generate_series(1, 100) i

Execute sql, don't care about result

sqlexec! create table t(i int, j int)

Define an xtable

pgxt give sql query an alias. Later you can refer to the alias using @foo@, or @foo.column@.

pgxt foo !select i, i*2 as j from generate_series(1, 100) i
pgxt bar !select i, i*2 as j from generate_series(1, 100) i
pgxt zoo !select @foo@.i, @bar@.j from @foo@, @bar@ where @foo@.i = @bar.i@
pgxt zoo # This is to print

Plotting

I use kitty, icat is an alias of kitty +kitten icat. Replace icat with your favorite image viewer.

pgxtplot line zoo    # plot zoo, each column will be a line, x axias is [0-n)
pgxtplot xline zoo   # plot zoo, first column as x axis. 
pgxtplot pie zoo     # pie chart, first column is category, second is weight.
pgxtexp zoo          # explain
pgxtexp zoo analyze  # explain analyze
pgxthist xtable col nbkt # histogram of xtable.col, in n buckets

pgxtctl

list, rm, clear, cleartmp, manage the xtables.

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

xontrib-xpg-0.1.2.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

xontrib_xpg-0.1.2-py2.py3-none-any.whl (8.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file xontrib-xpg-0.1.2.tar.gz.

File metadata

  • Download URL: xontrib-xpg-0.1.2.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for xontrib-xpg-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f3ff5e54189445aeb5f2d984fb08486d02ba2347946ebbc28ab082870a9bb568
MD5 5e061f3de91b88c97fbae3b0750e84e0
BLAKE2b-256 47ea41e74f2dc067d5956bea7bbcf9a1862ff5a43f94996e8ca1221f4e9e1993

See more details on using hashes here.

File details

Details for the file xontrib_xpg-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: xontrib_xpg-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for xontrib_xpg-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 442c42a571b04f5ba6e9689756fc348f0c0998ce12fbbb52a86960b26ff39c75
MD5 43b09524e665e565de008077996a2991
BLAKE2b-256 bc86dfbc185fa9e60e6998cabf69c04429cd5d04f2784d7b0bdf3f660b732de0

See more details on using hashes here.

Supported by

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