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.
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.
How to access sqlite from vba macro from here (original article in chinese) :
Software environment:
1) Win7 (32 bit) 2) Excel2007 (with VBA function)
Steps:
1) First,
http://www.zsplat.pwp.blueyonder.co.uk/programming/sqlite-3.5.7-odbc-0.65.zip
download and install the SQLite ODBC driver.
Note: If you use Win7, then you need to Adminitrator permissions,
otherwise the installation fails. The simplest step is to use the
Administrator login, and then install the SQLite ODBC driver.
2) Open the Excel VBA code editor window, the menu bar [tool] ->
[reference], adding Microsoft ActiveX Data Objects 2.7, the purpose is
to use VBA, and database connectivity.
3) Use the following code to connect SQLite database:
Dim conn As New ADODB.Connection
Dim dbName As String
'Define the connection string
dbName = "Driver = {SQLite3 ODBC Driver}; Database = D: \ yourdbname.db"
'Open the database
ff.Open dbName
ff.Execute "create table a (a, b, c);"
'Other operations on and VBA to connect to other DB like Access the same.
'Close connection
ff.Close
There're some DLLs that you can use to access a SQLITE Database from Visual Basic using adodb. I think here is the info that you're looking for. I never tried it, but the link can be usefull for you.
Good Luck.
I've used Datenhaus' dhSQLite and it works well.
google sqliteforexcel and download it from github
govert responded to this already (the creator), the easy solution to me, unless you can't.. don't use Access. Transfer the data to sqlite db files. You can even use ADO to a server or DAO and read the rs directly in to a sqlite table
It requires no driver or install. You can have your workbook download the 2 .dll's from a shared location on file open(check if they don't already exist on their file system, on say c:\temp), then user is running sqlite. I suspect, if you're so inclined to ask this, you'd want to write a function to loop calls to the appropriate sqlite functions(explained in example docs) and read returned data in to a vba array. Then you can do whatever you want with it.
Related
I am trying to get data from an AWS postgresql db into Excel and I am really struggling. When I select get data from postgresql it complains about missing additional components which I downloaded and installed but still the same issue.
I tried to use and ODBC connector but I have no idea how to use it and with many tries I still didn't get it right.
I have zero idea what to do. I currently connect to this db using Dbeaver, but thats not ideal.
I am able to connect to teradata using excel.
I dont even know what other info i need to provide here
You may find downloading the relevant data to a tab-separated value (TSV) or a comma-separated value (CSV) file first and then importing that into Excel might be easier to deal with than trying to hook into ODBC.
Almost every database client supports export to CSV and most also support TSV. Excel is really good at importing these kinds of files.
I am using advanced installer (simple) to create the setup project of a GUI i am making in visual studio. upon installation, it is possible to read data from the databse i.e the records that are already added can be read but as i try to save data in databse that function is not working and the application stops working. i think that the connection string is right that is why iam able to read data from it but why cant i update data. plz help.
the databse is is service-based local database
This might happen if you have the database stored in the same install location as your application binaries. Usually that is a folder under Program Files.
You're application cannot write under this location when running as a standard user, and it should never write/store data in that location.
If you're not using the Application Data folder to store your database, I suggest you update your app to do so, this should solve your problem.
Kofax Capture Version 9
I have an existing Project and Batch class that works, built previously by Kofax engineer.
What I need to do is change the script in the project to use a new DB connection. This seemed simple enough.
Using project builder I copied the existing project, altered the script and saved the project. Using Capture Administration I copied the existing batch class and then used Synchronize Kofax Transformation Project and pointed to the new project. All this seemed to work without error.
However the script being executed is the original not my altered one, any guidance would be great.
Make sure you are creating a new batch after publishing your change. The batch class class update function works in very limited scenarios, so I don't generally recommend it.
There are many ways that a database connection might be handled in script. Usually I would expect that a function at the project script level handles the connection and is called from any sub class, but you might want to check any sub classes to make sure they aren't using locally defined connection strings.
Even if you are making a connection in script (which you've now changed), you might also be using product features that use databases. Open Project Settings and check the Databases tab.
If there are relational databases listed, simply change as needed.
If you are actually using "Remote Fuzzy" databases then these might be using Kofax Search and Matching Server which connects to a relational database to build the fuzzy db. In this case you would need to use KSMS Admin to change the connection on the KSMS server.
If you are using "Local Fuzzy" databases then the info is based on the content of a text file. You might have some external process (possibly Markview) that dumps this text file from a database.
I have a broken installation of Ubuntu 14.04 - it won't boot, but I won't say anymore about that because that's not what I'm asking about really. I have a MySQL database (created using v5.5) on the broken Ubuntu installation and I need that data. I can get at the raw MySQL database files by mounting the broken installation onto another machine.
I actually need the database to be imported into a MySQL v5.1 installation. I tried copying the raw database files (e.g. the directory at /var/lib/mysql/dbname) into the same directory on the working OS installation. At first, it seemed like it worked, I can see the database, I can use it and I can list the tables. But it turns out that even though I can see the tables in the db, any attempts to describe or use them in any way give the 'table doesnt exist` error.
Ideally, I'd love to be able to use msqldump and then import the database the proper way, but how can I get a dump of the database if it's not part of the MySQL installation (remember, I can't boot into the installation, it's broken).
Of course, mysqldump is the most preferable solution, but if it's not possible to use that utility with the raw database files as input, then I'm willing to try anything that might work.
Of course the first thing you should do is to install the same version of MySQL as the original - if you're directly using the raw data files, keeping things as identical to the original as possible is a must! The same applies to paths, make sure the new installation and data files are placed in the same directory path that they were originally.
Once you have this, you can mysqldump the tables and use that to import into a clean, new installation.
I'm writing a SSRS report that is the direct result of a SSIS package.
It is my understanding that SSIS must have exclusive access to Excel files for import. Is there any way around this?
If I can't read what was there as of the last save, can I at least send an e-mail notifying the user of the failure? How do I catch that error?
This seems like a limitation of the Jet connection engine and Excel, by default, opens files in exclusive access mode. If there is only one or two people using the file, then you may be able to have them open the file in shared access mode to avoid this error. Or, since this is ultimately a Jet database engine connection, you might be able to specify in your connection string that you open it in Mode=Read.