vim-vdbc


Ⅰ. 插件描述

database interface for vim

Ⅱ. 基本信息

创建日期:  2014-01-24
使用用户:  1
Github星:  5
插件作者:  kamichidu

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'kamichidu/vim-vdbc'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'kamichidu/vim-vdbc'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'kamichidu/vim-vdbc'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/kamichidu/vim-vdbc

Ⅳ. 文档说明

vim-vdbc Build Status

The generic database interface for vim.

This plug-in intended to give some generic API to vim plug-in developers, and high-speed database
accessing (via vim's libcall feature).

Implemented features:

  1. transaction support
  2. prepared statement support
  3. introspection support (depends on a driver)

Installation

You can choose a driver you want to use it.
Available drivers are:

  1. pg
  2. pg_libpq
  3. sqlite3
  4. sqlite3_libsqlite3

After choosing your favourite driver, you can write following settings to $MYVIMRC.

NOTE: You have to install some dependencies.

  1. pg

    NeoBundle 'kamichidu/vim-vdbc', {
    \   'depends': ['Shougo/vimproc.vim'],
    \   'external_commands': 'psql',
    \}
  2. pg_libpq

    NeoBundle 'kamichidu/vim-vdbc', {
    \   'build': {
    \       'unix':    'make -f Makefile pg_libpq',
    \       'windows': 'make -f Makefile.win64 pg_libpq',
    \   },
    \}
  3. sqlite3

    NeoBundle 'kamichidu/vim-vdbc', {
    \   'depends': ['Shougo/vimproc.vim'],
    \   'external_commands': 'sqlite3',
    \}
  4. sqlite3_libsqlite3

    On this driver, we bundled sqlite3 sources and dynamic library for windows
    64-bit. If you use windows 64-bit, you can use sqlite3\_libsqlite3 driver without compiling it.
    
    NeoBundle 'kamichidu/vim-vdbc', {
    \   'build': {
    \       'unix': 'make -f Makefile sqlite3_libsqlite3',
    \   },
    \}

How to Use

Basic usage is below:

" driver is one of {'pg', 'pg_libpq', 'sqlite3', 'sqlite3_libsqlite3'}
try
    let conn= vdbc#connect_by_dsn('vdbc:sqlite3*:dbname=:memory:')

    call conn.execute('create table a_table (column1 integer, column2 varchar)')
    " => [[1, 'hoge'], [2, 'fuga'], ...]
    echo conn.select_as_list('select * from a_table where column2 = ?', ['param'])
    " => [{'column1': 1, 'column2': 'hoge'}, {'column1': 2, 'column2': 'fuga'}, ...]
    echo conn.select_as_dict('select * from a_table where column2 = ?', ['param'])
finally
    if exists('conn')
        call conn.disconnect()
    endif
endtry

See :help vdbc-contents for more details.

Dependencies

DriverOSDependencymake command example
pgUbuntu 14.xpostgresql-client-9.3-
Arch Linuxpostgresql-libs-
pg_libpqUbuntu 14.xlibpq5make INCDIR="-I/usr/include/postgresql/" pg_libpq
libpq-dev
Arch Linuxpostgresql-libsmake pg_libpq
sqlite3Ubuntu 14.xsqlite3-
Arch Linuxsqlite-
sqlite3_libsqlite3--make sqlite3_libsqlite3

添加新评论