vim-addon-sql : alias sensitive SQL completion (MySQL, Postgresql, SQLite)
script karma |
Rating 2/4,
Downloaded by 2682 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Marc Weber |
|
script type |
utility |
|
description |
KISS implementation of SQL completion for Vim:
First you have to connect to a database. Examples:
MySQL:
call vim_addon_sql#Connect('mysql',{'host':'127.0.0.1','database':'DATABASE', 'user':'USER', 'password' : 'PASSWORT'})
SQLITE:
call vim_addon_sql#Connect('mysql',{'database':'filepath'})
Postgresql (see code)
A connection only initializes b:db_conn which is a Vim object providing
functions for querying the database.
Setup mappings by calling this function:
call vim_addon_sql#UI()
In non visual mode the query start / end is determined by either ; or empty lines.
In visual mode the selection will be executed
Execution is done by command line tools (psql, mysql, sqlite(3))
The result of those queries is parsed by Vim to fill alias aware completion.
Example:
1)
SELECT *, CURSOR FROM table1, table2
Now CURSOR will only contain fields found in either table1 or table2
2)
SELECT *, a.CURSOR FROM table1 as a, table2
Now the completion will only contain fields of table1
Expect some minor bugs - however this it works quite nicely in practise.
camel case like completion is also supported. eg d_u -> db_users
Also completes MySQL internal functions
If you have any questions contact me. |
|
install details |
The *info* file in the top level directory contains all dependencies. I recommend using vim-addon-manager to install them all at once |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 142.132.191.50
|