-
Notifications
You must be signed in to change notification settings - Fork 0
alias sensitive SQL completion (MySQL, Postgresql, SQLite)
vim-scripts/vim-addon-sql
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a mirror of http://www.vim.org/scripts/script.php?script_id=2376 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.
About
alias sensitive SQL completion (MySQL, Postgresql, SQLite)