sql query tool
sqt
(sql query tool) is a cross-platform program to provide typical sql data source exploring and programming interface.
The subject was aimed to provide fast and convenient MS SQL query tool under linux. The only existing ODBC interface lead to support of any other ODBC data source. As a result of pgAdmin3 deprecation sqt
was modified to have a native PostgreSQL support via libpq. Due to my current needs PostgreSQL support is in priority.
The main target audience are db programmers.
Standalone (outdated) sqt for windows x64 (~12Mb)
hl.conf
for more details);Ctrl+M
, previous: Ctrl+,
, next: Ctrl+.
, last: Ctrl+L
);Ctrl+U
), lowercase (Ctrl+Shift+U
, Ctrl+Win+U
)Ctrl+Space
);Ctrl+J
);F6
);NOTIFY
) and messages (RAISE
).
Use COPY FROM STDIN
and COPY TO STDOUT
forms of the command with some magic in comments:
/*sqt { "copy_dst": ["/tmp/pg_stat_activity.csv", "/tmp/pg_stat_database.csv"] } */
copy (select * from pg_stat_activity) to stdout with (format csv, header);
copy (select * from pg_stat_database) to stdout with (format csv, header);
Specify an empty string instead of file name for output to the log widget:
/*sqt { "copy_dst": "" } */
copy (select * from pg_stat_activity) to stdout with (format csv, header);
copy_dst
may be used in case of single source query.create table tmp1 as select * from pg_stat_activity limit 0;
create table tmp2 as select * from pg_stat_database limit 0;
/*sqt { "copy_src": ["/tmp/pg_stat_activity.csv", "/tmp/pg_stat_database.csv"] } */
copy tmp1 from stdin with (format csv, header);
copy tmp2 from stdin with (format csv, header);
/*sqt
{
"interval": 1000,
"charts": [
{
"name": "sessions",
"y": { "active": "#0b0", "total": "#c00", "idle": "#00c" }
},
{
"name": "transactions, backends",
"agg_y": { "xact_commit": "#0b0", "xact_rollback": "#c00" },
"y" : { "numbackends": "#00c" }
},
{
"name": "tuples out",
"agg_y": { "fetched": "#cb0", "returned": "#0c0" }
}
]
}
*/
select count(*) total,
count(*) filter (where state = 'active') active,
count(*) filter (where state = 'idle') idle
from pg_stat_activity;
select
sum(xact_commit) xact_commit,
sum(numbackends) numbackends,
sum(xact_rollback) xact_rollback,
sum(tup_fetched) fetched,
sum(tup_returned) returned
from pg_stat_database;
interval
- interval to reexecute queries (milliseconds);
charts
- list of charts with names and graphical paths description;
agg_y
- cumulative values source.
/*sqt
{
"charts": [
{
"name": "tps_log",
"x": "ts",
"y": {
"f1": "#0c0"
}
}
]
}
*/
select s.ts, 5 + 4*random() f1
from generate_series(now(), now() + '20min'::interval, '1sec'::interval) as s(ts)
You may build the project by means of QtCreator or execute this sequence of commands from the project's root directory:
mkdir build && cd build && qmake ../src/sqt.pro && make
Qt toolchain must be installed and be available via PATH.
sqt
as useful as possible (+provide scripts for different dbms, versions, generic odbc data source);Some icons by Yusuke Kamiyamane. All rights reserved.