ewaters / altsql-shell Goto Github PK
View Code? Open in Web Editor NEWAn easily extensible DBI shell, perfect for a drop-in replacement to mysql-client
Home Page: http://ewaters.github.com/altsql-shell
An easily extensible DBI shell, perfect for a drop-in replacement to mysql-client
Home Page: http://ewaters.github.com/altsql-shell
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.
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.
Issue #14 is fixed on master, so releasing to CPAN would be good to update the changes since latest release
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.
Saying Error at pos 17, line 1
is just not that helpful
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>
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.
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.
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.
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
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.
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 you tab complete on table_name.
the '.' will be interpreted as any character in the regex. This should match on a literal period.
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.
Implement the MySQL features as a Model subclass
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.
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.
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:
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.
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
+----------+----------+-------------+--------------+
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) []>
If a table is long, we loose the ability to track which column is which. Show the header every 100 lines of output and/or at the end.
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).
Currently, the time to process a query that's reported is in seconds always, even if it spans minutes. It also reports rendering time, so if you go into a pager, it'll wait until the pager is done before calculating the time. This is a bug.
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).
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) %>
Non-intuitively, Term::Readline::Zoid
makes the backspace key act like the delete key if there's no characters before the prompt.
@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.
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.
Currently mysql reconnects are transparent to the user
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 |
'--------------------------'
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.
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;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.