Comments (13)
There's already the \crosstab
functionality, you'd be able to implement another different *View
in the tblfmt
package easily to support this. I don't think it'd be quite difficult, and I'd support a well implemented version. Sorting on the client wouldn't be difficult. In terms "pager" functionality, though, I'm not sure if you mean not using the system's less
/ more
, or what though.
from usql.
Also, if you're just looking for certain ways to find data, off-the-cuff, one can easily do this by piping usql
output to tools like sed
, awk
, perl
, ...
from usql.
@kenshaw Here's a 14 second screencast that shows US Census projections for 2019 preloaded in a table. In the screencast, I do the following steps:
- run a simple PostgreSQL command
table <table_name>;
to view the table. It loads it in pspg which provides limited sort capability. - then I select the state column, and sort it in descending order by pressing
d
. All data for Wyoming shows up on top, but the count_names are yet unsorted. - finally I select the county column, and try to sort it ascending order by pressing
a
. But that sorts the counties across states, as pspg doesn't have a feature (for reasons mentioned above) to do multi-column sort.
Not sure how else would a table viewer support multi-column sort with such simple keybindings without also folding the functionality of pager within its state. Like how would usql know which column has been selected by the user with a mouse click or key navigation? Perhaps a specialized pager like pspg can communicate with usql using some IPC mechanism?
multi-column.mp4
from usql.
Yes, I 100% understood what you meant. Is there a reason you don't just do this directly with your SQL query?
from usql.
The reason to not do this with SQL query is more of a UI question. If a user is already looking at a table, pressing a key to sort and unsort can show them in-place how the data changes. Also, another obvious reason would be speed: in my original request for such a feature in pspg, I asked if one can sequentially apply such sort operations and undo them too with simple keystrokes a
, d
, u
, arrow keys
. Btw, I updated my last comment with a suggestion for a IPC channel between pspg and usql. Perhaps pspg can exchange command information with usql on a socket to run queries on behalf of user, that way usql wouldn't have to reimplement pspg's functionality, and pspg wouldn't have to reimplement usql's functionality. @okbob
from usql.
I understand your ask, there are reasons this isn't done currently in psql
, which is: this isn't how psql
was designed to be used. You could hypothetically be retrieving millions, or hundreds of millions of records at a time. Keeping that data on the client side, to allow for easy reordering, would be problematic. In my opinion, humble as it is, the way psql
and usql
are made to be used is to easily and quickly do small queries at a time, or design "big queries" that are part of larger reporting systems. I can only speak for myself, and note: I'm open to enabling usql
to help others how they see best, but for what you're describing, I personally would be doing all of that from SQL directly.
from usql.
from usql.
You could hypothetically be retrieving millions, or hundreds of millions of records at a time. Keeping that data on the client side, to allow for easy reordering, would be problematic.
I agree, but that's not what I was thinking... Data will remain on server side, and won't be reordered on client side. usql
would update the query on request of pspg
each time user request a sort. usql already knows what table a user is currently viewing, it does not need to send the data regarding SQL query and data types to pspg (@okbob). pspg would send a note to usql with a list of tuples containing column numbers and sort direction. As a response, usql would send a new (modified) query to the server, and notify pspg to repage its input. pspg just needs to send a list of tuples that have column numbers and direction IMO.
from usql.
from usql.
We can avoid query parsing if it is a special command like (pick a better name perhaps): table_interactive <table_name>
instead of table <table_name>
. Then the command sent to the SQL server can be made by just appending order by <column-a> arc, <column-b> desc, ...
to basic table <table_name>
command. Though idk if there is a better option...
from usql.
from usql.
Maybe it is, idk. In my understanding and time with IPC mechanisms like sockets to act as command channels between processes, they can enrich existing CLI tools to avoid code and effort duplication. You already have great working pager pspg
that currently has 1-way data channel (pipe) IPC mechanism, if it has an option --socket
to have a command channel (socket) then a modern sql shell like usql
need not reimplement table features of pspg
.
from usql.
from usql.
Related Issues (20)
- Using password with special characters HOT 10
- Default USQL prompt font color(white) clash with default macos terminal default(white) background. HOT 2
- drivers_test.go drivers.Open incorrectly HOT 1
- mysql 5.7 without view check_constraints
- 2 security vendors and no sandboxes flagged this file as malicious HOT 1
- .usql_history file appears corrupt, no newlines saved?
- Support for NO_COLOR env variable HOT 2
- Add support for a password tool (Feature Request, not bug) HOT 3
- Oracle OCI Autonomous Databases, connection string?
- DuckDB Support
- possibility to redirect \d psql meta-command execution into a file HOT 4
- does not succed to export data in csv with \copy HOT 7
- Feature: Saving query string to output files HOT 10
- Published to pkgx
- Is there any plan to support parquet or orc format? HOT 2
- [PATCH] A handy conninfo output HOT 2
- error csv upload with pgx driver (encode date column) HOT 14
- Executing SQL files without semicolon as end-of-statement HOT 9
- Prevent irrelevant output with CSV format
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from usql.