Sunday, November 8, 2020

redirect result from psql to libreoffice calc

Sometimes can be useful to forward output query result from console to spreadsheet. Unfortunately, it is not trivial task, but it is not pretty hard too.

I have a table "obce" (It is "municipality" in Czech language), and I would to see the content of this table in spreadsheet. Then I can redirect output in csv format to libreoffice.

Now I can run psql and write command:

postgres=# select * from obce \g (format=csv) | cat > tmpfile.csv; libreoffice --view --calc tmpfile.csv "--infilter='Text - txt - csv (StarCalc)':44,34,0,1"; rm tmpfile.csv

The psql from Postgres 13 is required.

Tuesday, September 22, 2020

compiled dll of Orafce are available

 Compiled dll of Orafce extension 3.13 can be downloaded from url https://github.com/orafce/orafce/files/5264898/orafce_win_binary.zip

Thursday, September 17, 2020

new release of pspg - pager for PostgreSQL, MySQL, MonetDB, PrestoSQL, ...

I released new almost bug-fix release 3.1.4 of pspg. There is new light theme Flatwhite based on Dmitry Biletskyy flatwhite theme.



Saturday, September 12, 2020

Fedora 33 looks well

I tested Fedora 33 on my old Lenovo T510 (enhanced 16GB RAM). It looks pretty well. The interactive processes are quick under high load (what was some time problem in older releases).  It is very nice and comfortable.

Wednesday, August 19, 2020

Turbo Vision for terminals

I like terminal applications. When it is written in C language, then it is pretty fast, and it is different work. When I started my life with computers MS DOS terminals was stupid, computers was slow, but lot of MS DOS application had good look and comfort user interface. Unfortunately - lot of current terminal applications are ugly without comfortable user interface. I had nothing to special using vim or emacs or other Unix editors, but these editors are pretty unfriendly to occasional or new users. There are only few well look (and easy used) terminal applications - for me most important is mc and mcedit. 

When I worked on pspg I understood maybe why it is. There was not good libraries or frameworks for building these applications. NCurses is too level library. I had to write my own library for implementing menu - ncurses-st-menu.

There was more experiments about porting famous Turbo Vision framework to Linux environment with different success. One of these port is base for fp (Free Pascal IDE) editor. It looks well, but there is one significant limit. It doesn't support UTF8. 

 

There is another port of Turbo Vision to Linux https://github.com/magiblot/tvision with very interesting features. First - it still support DOS and Windows 10 builds. Second - it supports UTF8. It is pretty great project, and I hope so there will be more good look terminal applications based on this terminal. 

Some screenshots.

 

Thursday, August 13, 2020

New release of plpgsql_check - now with possibility to enable, disable checks, warnings, tracing inside functions

ADA language (ancestor of PL/SQL and PL/pgSQL languages) has PRAGMA clause for entering some compiler directives. Unfortunately PL/pgSQL has not this possibility, and it is very low possibility to have a PRAGMA in future. It is not a fundamental feature, but sometimes compiler directives can be practical.

When I use plpgsql_check, I usually find a parts of code with false alarms. The static analyse used by plpgsql_check cannot to work with dynamic SQL, it cannot to work with local temp tables, etc. Can be nice to have a possibility to disable check for these parts.

Now it is possible. I wrote special function plpgsql_check_pragma, that is identified by plpgsql_check, and plpgsql_check can read own directives from an arguments of this function. A implementation of pragma in plpgsql_check has static block or statement scope:

postgres=# create or replace function test_pragma()
 returns void
 language plpgsql
as $$
declare r record;
begin
  if false then
    -- check is disabled just for if body
    perform plpgsql_check_pragma('disable:check');
    raise notice '%', r.y;
  end if;
  select 10 as a, 20 as b into r;
  raise notice '%', r.a;
  raise notice '%', r.x;
end;
$$;
CREATE FUNCTION
postgres=# select * from plpgsql_check_function('test_pragma');
┌──────────────────────────────────────────────────┐
│              plpgsql_check_function              │
╞══════════════════════════════════════════════════╡
│ error:42703:11:RAISE:record "r" has no field "x" │
│ Context: SQL statement "SELECT r.x"              │
└──────────────────────────────────────────────────┘
(2 rows)

On systems without plpgsql_check you can write own empty implementation of plpgsql_check_pragma function (because probably you don't want to change already checked source code):

create or replace function plpgsql_check_pragma(variadic text[])
returns int as $$
  select 1
$$ language sql immutable;

This functionality is available from 1.13.0 release

Tuesday, August 11, 2020

Gnome-terminal with sixel support

I like terminal applications - usually TUI applications are fast and clean, and well readable.  This interface is too simply, and then developers has to much more think about UI, and has not too much possibilities. On second hand sometimes the output of terminal applications are too limited. We run our terminal from GUI (usually), and then some graphic possibilities can be practical - graphs are better in pixel graphics than ascii art.

There is solution - from terminal's dark age there is a SIXEL protocol. Unfortunately only few terminals supports this protocol. But there is great hope - Gnome terminal in develop version supports this protocol now. I can call gnuplot from psql and I can have well looked graphs in psql too.

For more comfort work I define a psql macro (variable):

\set gnuplot '\\g (format=csv) |gnuplot -p -e "set datafile separator \',\'; set key autotitle columnhead; set terminal sixelgd enhanced font \'verdana,9\';" -e'

and a statement

SELECT i, sin(i) FROM generate_series(0, 6.3, 0.05) g(i) :gnuplot "plot '-'with lines ls 3"

generates this image: