Created
July 26, 2014 13:10
-
-
Save aiya000/795fc1ee2193960b5853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"@See http://qiita.com/kamichidu/items/e3e6c16ed84b8f72de1b | |
function! PreviewDatbase(dbFileName, tableName) | |
try | |
let s:C = vdbc#connect_by_dsn('vdbc:sqlite3:dbname=./' . a:dbFileName) | |
let s:data = s:C.select_as_dict('SELECT * FROM '.a:tableName.';') | |
let s:columns = [] | |
for i in items(s:data[0]) | |
call add(s:columns, i[0]) | |
endfor | |
for indexText in s:columns | |
echon indexText | |
echon "\t" | |
endfor | |
echo "\n" | |
for row in s:data | |
for index in s:columns | |
echon row[index] | |
echon "\t" | |
endfor | |
echon "\n" | |
endfor | |
finally | |
if exists('s:C') | |
call s:C.disconnect() | |
endif | |
endtry | |
endfunction | |
call PreviewDatbase('test.db', 'Test') | |
call PreviewDatbase('test.db', 'Test0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment