Giter VIP home page Giter VIP logo

altsql-shell's People

Contributors

belden avatar brianphillips avatar ewaters avatar hoelzro avatar openstrike avatar spikegrobstein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

altsql-shell's Issues

Context-sensitive tab complete

If you tab complete in the where clause, we should be able in most cases to know which table(s) you are selecting from and can give you a list of only the columns from those table(s)

select * from accounts where \t gives you a list of only the columns in accounts

select * from accounts as a join orders as o on \t gives you a list of the columns in accounts, prefixed with a., and the columns in orders prefixed with o.

Detect failed 'use $database'

If you use mysql; but you don't have perms to do so, the app will still update the current_database() and attempt to update the auto complete data.

Cut a new release

Issue #14 is fixed on master, so releasing to CPAN would be good to update the changes since latest release

Sort last table result

Similar to issue #1, it'd be nice to take the table result and sort it according to a different column.

Perhaps something like this:

altsql> select country, count(id) from people group by country;
altsql> .sort country asc;

The count(*) and group by was an expensive operation. You don't want to have to execute it again just to change the sort order, but you'd like to see the data resorted on a different column. If you wanted it resorted according to the second column, you could use positional selector:

altsql> .sort column 2 desc;

This would result in the data being re-rendered but according to the new sort order.

Optionally support multisort declarations.

Differentiate cell padding from string data

Have some visual way of seeing the width of the data in each column.

altsql> select film_id, title from film limit 5;
.---------+------------------.
| film_id | title            |
+---------+------------------+
|       1 | ACADEMY DINOSAUR |
|       2 | ACE GOLDFINGER   |
|       3 | ADAPTATION HOLES |
|       4 | AFFAIR PREJUDICE |
|       5 | AFRICAN EGG      |
'---------+------------------'

In the above example, it's entirely unclear if the 2nd or 5th rows have extra spaces at the end of the title. This rendering would be identical if the title for 5 was AFRICAN EGG<sp><sp> or AFRICAN EGG or AFRICAN EGG<sp>

Personal config overrides (part of) default

I set a custom prompt in my ~/.altsql.yml as follows:


---
prompt: 'foo > '

No other entries.

The output with this configuration is ASCII only.

Looks like I need to add:

view_plugins: 
    - Color
    - UnicodeBox

In order for proper color and unicode output. Looks like the default is being overriden.

Setup Pages website

I'd like a friendly Pages website with screen casts of the tool being used and basic feature list to encourage users to adopt and fork the codebase.

Incremental reverse search issues

When you're in the incremental reverse search mode, you can get into a situation where it appears nothing is happening and that you're stuck. This happens when you've typed a string that doesn't appear in your history and you hit Ctrl-R. For example:

altsql> laksjd^R
i-search qr(laksjd): laksjd

At this point, any key you type will add to the incremental search but will not be registered on the screen. Further, Ctrl-C and Ctrl-D don't work. The only key you can type to escape this is Del, which will backspace from the end of the buffer. Once the buffer once again reflects items in your history, you can then Ctrl-C or Ctrl-D.

Export data easily in JSON, YAML, etc

One should be able to easily export data to a dump file. Possible syntax:

> select * from faq_questions limit 10;
> .dump ~/faq_questions.json

or

> select * from faq_questions limit 10 | .dump ~/faq_questions.pl format perl
  • Context sensitive; will guess output format based on the destination filename extension or by the 'format' argument.
  • Can be performed after a statement has already executed and displayed it's output so that you don't need to rerun a potentially lengthy command to get the same data you just saw
  • Out of the box support for the following formats:
    • Perl (eval() friendly or Storable)
    • JSON
    • YAML
    • HTML table
    • XML?

Configuration file initial support

Allow users to turn on and off which plugins they'd like to use in a configuration file.

Additionally, allow some of the display settings in Text::UnicodeBox::Table to be toggled there.

Avoid long running table calculations

Upon selecting a very large and wide data set, there is a lot of processing to be done to compute optimal UnicodeBox tables. Take this example I just ran into:

mysqlc> select count(*) from faq_questions;
┏━━━━━━━━━━┓
┃ count(*) ┃
┡━━━━━━━━━━┩
│ 12551    │
└──────────┘
1 rows in set (0.01 sec)

mysqlc> select max(length(answer)) from faq_questions;
┏━━━━━━━━━━━━━━━━━━━━━┓
┃ max(length(answer)) ┃
┡━━━━━━━━━━━━━━━━━━━━━┩
│ 1172                │
└─────────────────────┘
1 rows in set (0.02 sec)

A select * from this table hung for half a minute before I had to kill it; most likely took lots of time trying to draw the huge table.

  • If a select would generate a huge table, ask the user: "The resulting table would be #### wide and #### tall. Continue? (y/N)"
  • Alternatively, show an abbreviated output: "The resulting table would have been #### by ####; showing only #### rows with wrapping output"

Fullscreen pager doesn't clear itself

If you need to go to the fullscreen pager to view that's too long or too wide to view in the normal output, when you exit the pager you expect to return to what you were seeing, but instead it leaves droppings in the scroll buffer as well as on the screen itself. It may not be possible to have a pager go full screen and then return you to what you were looking at, but we could perhaps implement paging without going to full screen mode, or at least horizontal scrolling.

Alt+F does not work.

Typically in a system supporting readline bindings, Alt+B moves the cursor one word backward and Alt+F moves it one word forward. In AltSQL, Alt+B works, but Alt+F does nothing.

Strict/warnings issue

It appears that in some places in the code, the strict and warnings prgrama are not in place. For example, calling App::AltSQL::resolve_namespace_config_value as $view->resolve_namespace_config_value() is executed without strict or warnings. This is messed up.

Provide easy way to share tabular data

I often need to share tabular data (the output of a select statement) with others. Copy and paste works, but looses the color and bolding and often requires some work in Gmail to make it look decent.

Gmail supports pasting in of table markup, but how do we get that into the users clipboard?

Let's do this:

  • Easily post the query and results to a web service and return a tiny url link to it
  • The link lets you see the data clearly, search and reorder is as needed, and with a click of the button can copy the table to your clipboard for easy pasting as html
  • The web service would behave similarly to pastebin, can be internal for privacy, but shouldn't allow searching across all pastes

horizontal paging results in entire table jumping to top of terminal

SELECT * FROM customers;

Results in a nicely formatted table at the bottom of my terminal, just above the prompt. If I press right arrow to scroll to the right, the entire table jumps to the top of the terminal and then scrolls. It would be nice if either the table would scroll in place (without jumping to the top) or the table would be presented at the top to begin with to eliminate the jumping.

Narrowest possible display without wrapping

If your table has long column names but short values, most of the rendering is of white space:


┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓
┃ thumb_large_height ┃ thumb_large_width ┃ thumb_small_height ┃ thumb_small_width ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩
│ 0                  │ 0                 │ 75                 │ 100               │
│ 0                  │ 0                 │ 0                  │ 0                 │
│ 0                  │ 0                 │ 0                  │ 0                 │
│ 113                │ 150               │ 75                 │ 100               │
│ 113                │ 150               │ 75                 │ 100               │
│ 150                │ 113               │ 100                │ 75                │
│ 113                │ 150               │ 75                 │ 100               │
│ 113                │ 150               │ 75                 │ 100               │
│ 113                │ 150               │ 75                 │ 100               │
│ 113                │ 150               │ 75                 │ 100               │
└────────────────────┴───────────────────┴────────────────────┴───────────────────┘

Find a way to make this more narrow. Perhaps allow the header to span multiple lines:

thumb_large_height    thumb_small_height
  |    thumb_large_width  | thumb_small_width
  v              v        v            v 
+----------+----------+-------------+--------------+

warning issued by custom mysql prompt

I have this prompt in my .my.cnf file:

[mysql]
prompt=(\u@\h) [\d]>_

This issues a warning message if the database is not specified when I start altsql

Ctrl-C to reset the line; Ctrl-D to exit
Starting App::AltSQL
Use of uninitialized value in substitution iterator at /web/opt/perl/5.14/site/share/App/AltSQL/Model/MySQL.pm line 354.
(root@localhost) []>

Ctrl+C from paged results quits AltSQL

Although the shell correctly intercepts ^C whilst editing an SQL command line, Ctrl+C exits both the pager and AltSQL itself when viewing a query result with enough rows that the pager is being used.

Presumably, either ^C should drop back to the AltSQL command line, or it should be a complete NOP (as in VIM).

Null characters display inconsistentely

If you force pagination by narrowing your console window to force the following output to paginate:

select 'This is a long string that will cause the output to paginate', char(0);

You'll notice that the null character in wide output shows up as an empty, zero length string, but in less it shows up as a grey '^@' which upsets the formatting of the table output (the expected display width of that character was 0).

Variable substitution

Allow Perl code to be substituted in the statement you're executing.

select id from table_a limit 1;
select * from table_b where id = <% $buffer->last->row(0)->column(1) %>

Split large queries into chunks; run each in parallel

@gt8073a suggests a feature where one could take a large query which will be fairly resource intensive on the server side and find a way to split it up into smaller chunks and run each in parallel in the background, waiting for the results and then putting them together in such a way as to make it transparent to the user.

Don't accept term command if ';' is EOL but within a quote

This should work:

altsql> select * from film where title = ";
";

This means: select * from film where title = ";\n"
We need to look at the buffer and determine if the ';' or '\c' or '\g' is within a quote scope before treating it as an EOL signifier.

Multi-line per row wide output

Rather then requiring wide output to be horizontally scrolled, there are a few options to format wide data on a narrow screen. This is one of them. Find a way to wrap the cells of a row in a sane fashion. Here's a very simple example:

.----+---------------------.
| id | ts                  |
| log                      |
+----+---------------------+
| 1  | 2012-04-16 12:34:16 |
| blakblkj welkjwe         |
+----+---------------------+
| 2  | 2012-04-16 16:30:43 |
| Eric was here            |
+----+---------------------+
| 3  | 2012-04-16 16:31:43 |
| Eric was here again      |
'--------------------------'

Allow schema to inform column alignment

Currently the Text::UnicodeBox::Table aligns all numbers to the right and non-numbers to the left. This is not what mysql-client does, and should use the schema to inform which direction to align.

Select all columns except...

Sometimes it's nice to select * from table but omit one of the columns. To do this currently, you have to then explicitly list each column name. How about something like this:

select .all_except(picture) from staff;
select /* all except picture */ from staff;
select *.except(picture) from staff;
select * except picture from staff;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.