sponsor Vim development Vim logo Vim Book Ad

sql_tool_swb : run sql statements using sql workbench/j

 script karma  Rating 0/0, Downloaded by 581  Comments, bugs, improvements  Vim wiki

created by
leo du
 
script type
utility
 
description
This plugin run your SQL statements and show results in a split window.
Works on both Linux and Windows.

Requires SQL Workbench/J (http://www.sql-workbench.net/)

It works with any DBMS supported by SQL Workbench/J (PostgreSQL, Oracle, SQLite, MySQL, SQL Server etc.).
See the complete list here: http://www.sql-workbench.net/databases.html.

Usage:

use this key sequence to select/change sql connection: \swl

use this mapped key sequence to run sql: \se
In normal mode, this runs the line where cursor is on;
In visual mode, this will run sql that was selected;

Prepend block:
sometimes it is convenient to prepend your sql with some static statment.
It can be done by starting your sql file with a block:  /* PRE: <some statements> */

In addition, a Sql Workbench/j connection profile can also be specified with WbProfile=<profile_name>; on the first line.

below is an example file:
1 /* PRE: WbProfile=ConnProfile1;
2     USE EmployeeDB;
3     WbVarDef EID=250;
4  */
5
6 Select * From Employees Where EmployeeID=$[EID];
7
8 Update Employees Set Sal=Sal*1.5 Where EmployeeID=$[EID];
 
install details
Requirement: Install SQL Workbench/J (http://www.sql-workbench.net/), and have some working connections.

Install:Standard Vimball install, or just unzip and copy the vim script to your plugin folder.

Vim Setup:
Set these two values in _vimrc:

"path to java bin
let g:sqlwbc_java_bin = '/usr/bin/java'
"path to sql workbench/j jar file
let g:sqlwbc_swb_jarfile = '~/sqlworkbench/sqlworkbench.jar'

 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
sql_tool_swb-v1.3.3.vmb 1.3.3 2024-02-22 7.4 leo du convert from global plugin to ftplugin for (sql files only);
convert to vim9 script;
ip used for rating: 18.116.40.177

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github