jum4 / sublime-sqlexec Goto Github PK
View Code? Open in Web Editor NEWA Plugin for running SQL commands in Sublime Text
Home Page: http://lubriciousdevelopers.github.io/projects/sublime-sql-exec
A Plugin for running SQL commands in Sublime Text
Home Page: http://lubriciousdevelopers.github.io/projects/sublime-sql-exec
I installed the plugin sublime-sqlexec followed the steps as in the official site and executed the query but it doesn't show the output.And after that i opened my console window it showed
AttributeError: 'Window' object has no attribute 'create_output_panel'
I am using sublime text2 in windows7.Please help me to fix this issue.Any help would be appreciated
Hi, how do I clear history?
I don't use a password for my local postgresql database so I didn't specify the password
property for my connection. This worked so so.. This is what the console gives me when I try to List connections
:
Traceback (most recent call last):
File "SQLExec in /Users/jacob/Library/Application Support/Sublime Text 3/Installed Packages/SQLExec.sublime-package", line 140, in sqlChangeConnection
File "SQLExec in /Users/jacob/Library/Application Support/Sublime Text 3/Installed Packages/SQLExec.sublime-package", line 120, in __init__
KeyError: 'password'
Just adding "password": ""
fixes it but I thought this might be worth mentioning.
Superb package. I was looking at your code trying to figure out how I might modify it to get output in a new window and found that the option was already there!
Can you add this "hidden" setting to your Wiki? Thanks again.
Hello,
Just installed the plugin and it's pretty awesome.
We, however, have our production DB in the cloud and it's not directly accessible from localhost.
Would you support the addition of this feature? See here, for instance.
Using this setup:
{
"show_result_on_window": true,
"connections": {
"MyDbNickname": {
"type" : "oracle",
"host" : "db.company.com",
"port" : 1585,
"username": "myusername",
"password": "mypassword",
"database": "tnsname",
"service" : "tnsname"
}
}
}
I always get the same error of
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
SP2-0306: Invalid option.
which makes me wonder if the connection string is being passed incorrectly or if I'm just setting it up incorrectly?
My $PATH is set correctly, as a string of
sqlplus myusername/mypassword@tnsname
works just fine from the command line, and other sql apps find the tnsnames.ora file just fine.
Passing the password as a command argument can lead to security issues (even MySQL throws a warning when you do it).
One solution could be to allow the user to set a particular string for the arguments (sql_exec.args), so the user can delete the -p parameter and rely on a ".my.cnf" file to store the password in it.
Is it possible to do that on the current version? Does it sound like a good idea?
Hi,
I find this plug in amazing, it helps me everyday and make my life beautiful (not sarcasm). Working on Oracle, I prefer work on sublime Text.
I would like to set the "before" of my database without editing the plugin (sgbd/oracle.sqlexec) itself to put my "output parameters". like :
SET LONG 100
SET PAGESIZE 0 EMBEDDED ON
SET HEADING ON
...
I send that cause, you just published an update and I lost all my parameters.
I love updates so don't worry ;-)
Thank you ! <3
Does Slite3 supported?
Hi guys,
I installed sqlexec but get the error "/bin/sh: psql: command not found"
upon executing a query from sublime 3.
I have the psql binary stored under
"/Applications/Postgres.app/Contents/Versions/9.3/bin/psql"
I also have them symlinked under /usr/local/bin.
Upon running "sh" from the terminal and checking out the PATH variable, I get the following which contains the directory where all the psql binaries are
sh-3.2$ echo $PATH
/usr/local/heroku/bin:/Library/Ruby/Gems/2.0.0/cache:/Users/nitin/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Thanks
Hi,
Thanks for making this awesome plugin. While it works very well when I inline my entire psql query, I do get an error if I split even the simplest query such as the one down below into multiple lines
select count(*)
from mytable
ERROR: syntax error at or near "from"
LINE 1: from mytable
-- This will work though
select count(*) from mytable
This naturally limits the ability to perform complex queries. Let me know if you are aware of this issue and if I can help fix it. Thanks
After expression are executed, the message window contains symbols in wrong encoding. i guess it's possible to check whether is good encoding for a computer or add an option to change it, thank you
When "SELECT 1;" it's ok. but not in "SELECT 1 AS 2;"
when i write a wrong sql query dont show me the error, just show me the query, i installed by package control :S
First of all, great plugin!! :)
Second, the output gets displayed in some kind of "panel", I'm guessing by this code:
class Command:
def __init__(self, text):
self.text = text
def _display(self, panelName, text):
if not sublime.load_settings("SQLExec.sublime-settings").get('show_result_on_window'):
panel = sublime.active_window().create_output_panel(panelName)
sublime.active_window().run_command("show_panel", {"panel": "output." + panelName})
else:
panel = sublime.active_window().new_file()
panel.set_read_only(False)
panel.set_syntax_file('Packages/SQL/SQL.tmLanguage')
panel.run_command('append', {'characters': text})
panel.set_read_only(True)
Is there some way to focus this panel with a keyboard shortcut?
Sometimes when the output gets large I want to be able to scroll in it and maybe do a ctrl+f in some large Desc Table results.
Hi,
I'm trying to configure sqlexec for Greenplum Database( A flavour of postgreSQL)
But Im getting below error
"Error trying to parse setting : Unexpected trailing character in Package"
Here is my configuration file
"sql_exec.commands":
{
"psql" : "/usr/local/greenplum-db/bin/psql"
}
{
"connections":
{
"Connection 1":
{
"type" : "psql",
"host" : "10.26.96.100",
"port" : 5432,
"username": "gpadmin",
"password": "changeme",
"database": "yogesh"
}
}
}
Is there any other way to install SQLExec, I cant find it in package control. I am getting this error when I add it manually.
Error trying to parse file: Trailing comma before closing bracket in ~/Library/Application Support/Sublime Text 2/Packages/SQLExec/Default (OSX).sublime-keymap:8:1
when i edit the default settings file from inside ST3 it opens "Base File.sublime-settings", but plugin looks for "SQLExec.sublime-settings". Renaming the file does the trick, but thet means you can edit settings from Preferences>Package Settings>SQLexec>Settings - Default
the issue seems to be here (sqlexec.py - line 128):
connections = sublime.load_settings("SQLExec.sublime-settings").get('connections')
Some characters, that are considered as special characters by the shell, will produce an error when trying to execute the command, because they are not correctly escaped.
For example, if your password contains a '<' character, the command that will be issued to the shell will look something like this:
`mysql ... -Pmy<password ...``
That will make the shell look for the file named "password", in order to use it as input for the command.
I'll make a Pull Request in just a moment.
The command "desc table" only shows tables in the public schema. Can be easily fixed in the /sgbd/pgsql.sqlexec file but I'm wondering if you've kept support for that out for performance purposes.
Hi,
Just suggestions. Thank you.
i followed the steps but if i use ctrl+e 2x tell me "No active connection"
I this project dead? There are outstanding pull requests and issues. If you don't have time, add me as a collaborator so I can do merges.
Otherwise, I'll be taking over the project under my own fork.
I have configured plugin like that in user settings):
{
"sql_exec.commands": {
"oracle" : "sqlplus"
},
"connections": {
"name": {
"type": "oracle",
"host": "hostnamee",
"port": port_number,
"username": "user",
"password": "pass",
"database": "sid",
"service": "sid"
}
}
}
But when I try to run any query (select sysdate from dual;
) I get this in output window:
Traceback (most recent call last):
File "SQLExec in C:\[path]\Sublime Text 3\Installed Packages\SQLExec.sublime-package", line 172, in executeQuery
File "SQLExec in C:\[path]\Sublime Text 3\Installed Packages\SQLExec.sublime-package", line 29, in execute
File "SQLExec in C:\[path]\Sublime Text 3\Installed Packages\SQLExec.sublime-package", line 16, in _getCommand
File "SQLExec in C:\[path]\Sublime Text 3\Installed Packages\SQLExec.sublime-package", line 13, in _buildCommand
AttributeError: 'Options' object has no attribute 'service'
Any help would be much appreciated!
In order to use temporary tables in PostgreSQL, is it possible to keep session between two queries in Sublime ?
Réf. : http://www.postgresql.org/docs/8.4/static/sql-createtable.html
TEMPORARY or TEMP
If specified, the table is created as a temporary table. Temporary tables are automatically dropped at the end of a session, or optionally at the end of the current transaction (see ON COMMIT below). Existing permanent tables with the same name are not visible to the current session while the temporary table exists, unless they are referenced with schema-qualified names. Any indexes created on a temporary table are automatically temporary as well.
Searching through the repository I cannot find any mention to open source licence. By this project being on Github, I am allowed to fork it by the Github TOS (Terms Of Service). However I am not allowed to create derivative works from it (pull requests). Meaning I cannot fork this repository, change its code and perform pull requests without the danger/liability of being prosecuted by violating the All rights reserved
copyright granted by berne convention law.
The original prime theme for Sublime Text has the licence following open source licence:
The MIT License (MIT)
Copyright (c) 2014 Karel Vuong
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Can the project have the same licence?
Related issues:
Could someone kindly document exactly how to connect to a Postgres database? The settings shown on http://lubriciousdevelopers.github.io/projects/sublime-sql-exec/ and here are vague and conflicting at best. It is recommended to use the pgpass.conf method yet the sample configuration file on lubriciousdevelopers web site shows much of the same information that .pgpass provides
"Connection 2": {
"type" : "pgsql",
"host" : "127.0.0.1",
"port" : 5432,
"username": "anotheruser",
"database": "dbname"
},
What is the exact string necessary for "sql_exec.commands" in SQLExec.sublime-settings? A sample syntax for MySQL is provided but not for any others. A sample for pgsql would help greatly for its methods of execution are not as simple as other software.
I have spent the better part of an hour to make this work on Postgres to no avail. Setting up for MySQL was a snap,
As a web developer I run MySQL and Postgres. This is from my SQLExec.sublime-settings file:
{
"show_result_on_window" : true,
"sql_exec.commands": {
"mysql" : "/usr/bin/mysql",
"pgsql" : "psql",
//In my Ubuntu environment: set PGPASSFILE=~/.pgpass.
//.pgpass conforms with hostname:port:database:username:password
},
"connections": {
"Connection 1": {
"type" : "mysql",
"host" : "127.0.0.1",
"port" : 3306,
"username": "root",
"password": "a_password_entered-here",
"database": "a_db"
},
"Connection 2": {
"type" : "mysql",
"host" : "127.0.0.1",
"port" : 3306,
"username": "root",
"password": "a_password_entered-here",
"database": "a_db"
},
"Connection 3": {
"type" : "pgsql",
"host" : "127.0.0.1",
"port" : 5432,
"username": "a_username_is_entered_here",
"password": "a_password_entered-here",
}
}
}
Every time i try to execute a simple select query my SublimeText crashes !
this is my settings:
{
"sql_exec.debug": true,
"sql_exec.commands": {
"mysql" : "C:/wamp/bin/mysql/mysql5.6.12/bin/mysql.exe"
},
"connections": {
"Connection 1": {
"type" : "mysql",
"host": "127.0.0.1",
"port": 80,
"username": "root",
"password": "",
"database": "test"
}
}
}
any solution ?
I really like your tool and happily use it regularly. Sometimes I issue a wrong query (e.g. I forget to limit a query which results in a time-consuming query). Is it possible to cancel the issued query? (Like ctrl+c
in the terminal.)
Greetings! Can you run that list of commands through set(), or something, to remove the duplicates? Thanks again, excellent package.
I did a fresh install via the Package Manager and when I try to list the connection list nothing happens and I get this in the ST3 console:
File "SQLExec in /home/andrei/.config/sublime-text-3/Installed Packages/SQLExec.sublime-package", line 140, in sqlChangeConnection
IndexError: list index out of range
Even if I add some connections here:
( Preferences > Package Settings > SQLExec > Settings - User )
It still crashes.
I hope this reproduction helps you.
Thanks,
Andrei
I'm trying to connect to Vertica with VSQL.
Plugin is installed in ST3 on Ubuntu 14.04.
Traceback (most recent call last):
File "/opt/sublime_text/sublime_plugin.py", line 526, in run_
return self.run()
File "SQLExec in /home/cc/.config/sublime-text-3/Installed Packages/SQLExec.sublime-package", line 183, in run
File "SQLExec in /home/cc/.config/sublime-text-3/Installed Packages/SQLExec.sublime-package", line 35, in desc
File "SQLExec in /home/cc/.config/sublime-text-3/Installed Packages/SQLExec.sublime-package", line 18, in _getCommand
KeyError: 'before'
I installed sqlexec and this is my configuration in ( Preferences->Package Settings->SQLExec->Settings User ):
{
"connections": {
"Connection 1": {
"type": "mysql",
"host": "127.0.0.1",
"port": 3306,
"username": "root",
"password": "1234",
"database": "zlcms"
},
},
"sql_exec.commands": {
"mysql": "C:\\xamp\\mysql\\bin\\mysql.exe"
}
}
i think mysql path is wrong, i try changing the path to "C:/xamp/mysql/bin/mysql.exe" but it's not working, please help me!.
sublime text 3 beta gets blocked when password is set to empty. Maybe mysql asks for password and never returns anything. Solved by deleting "-p" parameter in file mysql.sqlexec:
From: "args": "-h{options.host} -P{options.port} -u{options.username} -p{options.password} -D{options.database}",
To: "args": "-h{options.host} -P{options.port} -u{options.username} -D{options.database}",
Any chance of displaying the results in a sublime window instead/optionally?
Then you can take advantage of all of sublime's editing features, whereas it doesn't seem like you can search/multi select etc in the output pane.
When I press 'ctrl+alt+e' key-binding to select connection, it doesn't try to do anything. Works great on my linux box at home. Just won't try at all on my mac box. I've tried sublime.log commands to True to see commands in the console and when I press 'ctrl+alt+e'...nothing. What can I do?
Hi there,
currently a connection like this discosiders the password:
{
"connections": {
"dev": {
"type" : "pgsql",
"host" : "localhost",
"port" : 5432,
"username": "username",
"password": "passssssword",
"database": "dev"
}
}
}
pgsql.sqlexec does not apply options.password anywhere (because the psql command does not support it, I am aware).
However, you can give the password as a PGPASSWORD parameter in bash. Hence, here is my current workaround for if anybody needs it:
{
"sql_exec.commands": {
"pgsql" : "PGPASSWORD=passssssword /usr/local/bin/psql",
},
"connections": {
"dev": {
"type" : "pgsql",
"host" : "localhost",
"port" : 5432,
"username": "username",
"password": "",
"database": "dev"
}
}
}
Connecting with a MySQL user that does not use a password does not seem to be possible with this plugin as it currently stands. It would just take a change to line 5 at https://github.com/jum4/sublime-sqlexec/blob/master/sgbd/mysql.sqlexec for that, but alas I just use the following instead:
http://bartinger.at/execute-mysql-from-sublime-text-2/
Hope this helps.
BTW It's much nicer to execute the query from the currently open source file than from the console... it would be cool to format the results like this plugin does, but execute the currently open file.
When i use ctrl+e ctrl+e dont do anything, i follow all the steps :S
Console error:
Traceback (most recent call last):
File "./sublime_plugin.py", line 339, in run_
File "./SQLExec.py", line 200, in run
File "./SQLExec.py", line 29, in execute
File "./SQLExec.py", line 88, in show
File "./SQLExec.py", line 74, in _result
File "./SQLExec.py", line 66, in _display
AttributeError: 'Window' object has no attribute 'create_output_panel'
Would this be hard to implement?
On a german keyboard you hit AltGr + E for the euro sign
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.