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
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
xontrib-xpg-0.1.0.tar.gz
(8.2 kB
view hashes)
Built Distributions
xontrib_xpg-0.1.0-py3.8.egg
(13.3 kB
view hashes)
Close
Hashes for xontrib_xpg-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ca840b54d38339da1e7f97d13d042173f3fc16b8681d9aad999bdbba942516b |
|
MD5 | f8141458f962b6a5a30157f87820edb1 |
|
BLAKE2b-256 | e26a5c8032d8062f9e8e01fc590a7ae4101a1a0c81fe032de2735912c1234e86 |