Sublime Forum

DB1: Sublime Text Database Client


Hey you guys! I just wanted to show you the database client I’ve been working on for awhile.

Basically, it turns Sublime into a full featured database client for MySQL, PostgreSQL, SQLite and MariaDB, and it doesn’t require or depend on local database installation either.

Any view can be used as a place for query execution, and query results can be exported to either another view (which I call the Results Window) or to an output window at the bottom of the window you’re executing in.

Here’s a picture that shows execution to the Results Window:

And here’s a picture that shows execution to the Quick Query view:

As I mentioned above, the currently supported database types are MySQL, PostgreSQL, SQLite and MariaDB, and once you connect to a database successfully, the connection will be stored for future use (every time you connect to a database, you’ll be shown a list of these stored connections you can choose from).

In addition to this, I worked really hard to make query execution as simple as possible. You execute queries from a view, using the execute sql command. If there is no text highlighted in the view you’re executing queries in, then the entire view will be parsed for queries, and then executed against a database. I’ve found this makes it super easy to store queries, procedures and functions in files, and then just open the files and execute them.

Alternatively, if there is a selection in the view, or multiple selections, then just those queries will be executed. Here’s a cool example of multiple selection query execution. If you use the query

select title, director from movies limit 100;

and use multiple selections to select “select title” and “from movies limit 100;” then the query “select title from movies limit 100;” will be executed. In other words, using multiple selections with queries makes it super easy to just execute portions of the query without having to copy/paste or delete parts of them. You can also select whole queries using multiple selections and those queries will be executed.

Another pretty cool feature is Query Templates. Query Templates allow you to tie SQL statements with optional variables to keyboard shortcuts.

A a simple query template could look like:

        "keys": "command+shift+1"],
        "command": "db1_execute_template",
        "args": {
            "mysql_pattern": "select * from %s;",
            "postgresql_pattern": "select * from %s;",
            "maria_pattern": "select * from %s;",
            "sqlite_pattern": "select * from %s;",
            "output_type": "quickpanel"

If you highlight the word “movie” in a view, and hit the keyboard shortcut “command+shift+1” then the query “select * from movie” will be executed. Obviously, just one “_pattern” arg is required for the database type you’re executing against. You can also use as many “%s” variables as you’d like. I’ve used query templates to make a ton of daily database tasks simpler.

In addition to the above there’s a ton of other stuff you can customize, including appearance of the results, and connection settings. As a final note, I do charge for licenses to DB1, but just like Sublime you can trial it free forever, with no limitation to functionality.

Here are some links to additional information:

Homepage with example videos and feature demonstrations
Issues and Feature Requests
Package Control Link

Feel free to ask any questions, and or ask about features here! I’ll do my best to answer them!

1 Like


@alexggordon, i have install the package successfully, but i can not access the table by myself.
for example, i have a table crm_t_project in my database, when i execute the script:’ select * from crm_t_project’, the plugin response a error:relation “crm_t_project” does not exist.

could you tell me how to fix the issue?
wait for your response.



@alexggordon, i have check the issue again, i fond i can not change the database.
at the beginning, i connect to database ‘postgres’ , and then i change the database to ‘demo’ by the command ‘Change Database’, but i am still in the database ‘postgres’.

could you tell me why the command ‘Change Database’ does not work, and how to fix the issue?
wait for your response.



I can’t find DB1 in Package Control list. Is there some other way to install?



@dannydyer, it’s marked as missing on the Package Control site. Have you tried the SQLTools package?



No, I didn’t try this yet. Thanks!