Monday, November 20, 2017

Re: ANN: dbext.vim version 26.00 - Database access from within Vim



On Fri, Nov 17, 2017 at 6:22 PM, Philip Rhoades <phr@philiprhoades.org> wrote:
 
This looks very interesting but even the tutorial is overwhelming - for a quick start, what is the simplest way for me to connect to:

  /home/phil/src/ruby/sqlite.db

and execute a query like:

  .tables

Probably the easiest way is:

1. Before launching Vim, make sure the sqlite binary is in your path.

2. I assume plugin/dbext.vim has already been sourced (:DBGetOption returns something successfully)

3. Execute the following to specify connection information (fastest easiest way):
         :DBSetOption type=SQLITE:user=:passwd=:dbname=/home/phil/src/ruby/sqlite.db
         - Usernames and passwords are not used by SQLite, so we blank them out from the default here

4. Execute the following command
         :DBExecSQL .tables

Connection: T(SQLITE)  D(/home/phil/src/ruby/sqlite.db)   a
am                 fd_group           recipe             vf
am_zero            food_des           rm                 vf_zero
ar                 mealfoods          rm_zero            weight
archive_mealfoods  meals              sql_statements     weightslope
dv                 nut_opts           tcl_code           wlog
dv_defaults        nutr_def           theusual
fatslope           options            version


Instead of step #3, you can also run :DBPromptForBufferParameters.  You may have to run through this twice removing the "@askb" for username and password.  The 2nd time will allow you to enter the database name.

And that is why I would add the following to my .vimrc:
let g:dbext_default_profile_ANYTHINGYOUWANT = 'type=SQLITE:dbname=/home/phil/src/ruby/sqlite.db'

So that when you run:
:DBPromptForBufferParameters

You would simply choose:
ANYTHINGYOUWANT

From that list, which is just far easier in the long run when you use these databases on a regular basis.


Hope that helps,

David

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment