Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access SQLite from VBA?

Tags:

sqlite

excel

vba

I have an Excel workbook that has some adodb code that queries a local access database. I want to do the same for SQLite as I believe that will provide better performance. How do I do that? Can I connect to an SQLite file using adodb or odbc?

I need something simple that I can deploy so that if i can minimize unnecessary configuration and installation maybe peoople that will be using the excel won't have admin rights on the pc so they can't install software.

like image 363
user161259 Avatar asked Aug 28 '09 13:08

user161259


Video Answer


1 Answers

Facing the same question, I made a lightweight library to give direct access to SQLite3 from Excel VBA. The end result is a much simpler solution, with no intervening ODBC or OleDb/ADO layer, and the performance reflects the SQLite database performance and not that of the opaque wrapper. It's also nice because you need no registration of a COM component in the registry, you just copy two .dlls with your workbook and add a .bas module into your project.

A disadvantage of this approach is that the API is not the standard DAO or ADO interface, so you might need to make some wrappers, or convert some of your code to make it work. That also means you need some familiarity with the SQLite API to use it, but the SQLite documentation is very clear.

I have put an early version of the project on CodePlex: SQLite for Excel provides a high-performance path to the SQLite3 API functions, preserving the semantics of the SQLite3 library calls and allowing access to the distributed SQLite3.dll without recompilation.

Any feedback would be much appreciated.

Update: The SQLite for Excel project now lives on GitHub.

like image 102
Govert Avatar answered Sep 19 '22 15:09

Govert