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

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

xpg-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distributions

xpg-0.1.0-py3.8.egg (13.3 kB view details)

Uploaded Source

xpg-0.1.0-py2.py3-none-any.whl (6.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file xpg-0.1.0.tar.gz.

File metadata

  • Download URL: xpg-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 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.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for xpg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2801e2ce997e7844d206cd606e6fc78950599225c2eb8964c077f51c02dfb874
MD5 637a0b793323a9e1ab3184a87bd0cb31
BLAKE2b-256 0e88abc90f0ff178ca781bdb89ef01bc1a3337eb945f7f754999f43ca03598f0

See more details on using hashes here.

File details

Details for the file xpg-0.1.0-py3.8.egg.

File metadata

  • Download URL: xpg-0.1.0-py3.8.egg
  • Upload date:
  • Size: 13.3 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.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for xpg-0.1.0-py3.8.egg
Algorithm Hash digest
SHA256 84ebc3948446035fc622131d0f3098229f47e27551347e72941eb2b6a7e4ba3c
MD5 394d0c7998d0eef0fcdf709fa99a83d9
BLAKE2b-256 949abf6564182158161b6a72346c25958563781cd986d0d464631ada1e10a233

See more details on using hashes here.

File details

Details for the file xpg-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: xpg-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.8 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.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for xpg-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bcf9173b3a9220373d5e32a9029fd4d71313168304c0dfe7330a7a3eac2c3216
MD5 52d547db3d817b74f90a9e6300e9173b
BLAKE2b-256 e7784ffba678748ce142081bbba748ad24f02e361ac2d1b3f12e8986c822b215

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