Jump to content

SQLite and LabView


Recommended Posts

I've been working with SQLite 3 (www.sqlite.org) for the last couple of days. And had good success with and had some good success in developing a wrapper for SQLite that can easily be used in LabView. I'm writing this wrapper in LabWindows/CVI, but it is all standard ANSI C, and not very much of it anyway. I was wondering if there is a call for an embedded database like SQLite in the LabView world. I don't use databases very much but when I ran across an article about SQLite I couldn't resist toying with it. I have no problem posting the code, if there is interest, and I think it could prove to be a useful addition to the OpenG toolkit, if there was a call to develop it into a library compatable with OpenG. One nice thing is that SQLite is at least as cross-platform as LabView!

I await your responses!

Chris Davis

Link to comment
I've been working with SQLite 3 (www.sqlite.org) for the last couple of days. And had good success with and had some good success in developing a wrapper for SQLite that can easily be used in LabView. I'm writing this wrapper in LabWindows/CVI, but it is all standard ANSI C, and not very much of it anyway. I was wondering if there is a call for an embedded database like SQLite in the LabView world. I don't use databases very much but when I ran across an article about SQLite I couldn't resist toying with it. I have no problem posting the code, if there is interest, and I think it could prove to be a useful addition to the OpenG toolkit, if there was a call to develop it into a library compatable with OpenG. One nice thing is that SQLite is at least as cross-platform as LabView!

I await your responses!

Chris Davis

Maybe you can educate us a little bit. I've worked with several database engines but not SQLite. I understand it's embedded. Does this mean you cannot access it from an ODBC interface? Can you create a DLL that can be called through LabVIEW?
Link to comment
Maybe you can educate us a little bit. I've worked with several database engines but not SQLite. I understand it's embedded. Does this mean you cannot access it from an ODBC interface? Can you create a DLL that can be called through LabVIEW?

Not a problem. SQLite is an embedded database, which means that the database you create is just a single file on your computer. This single file can be backed up easily and even moved across platforms (windows, mac, linux) to be read using the appropriate SQLite DLL ( or shared library on other platforms). It claims speed as one of its advantages, but I can't back that up with any hard numbers. In my case, the speed of execution is not as important to me as other properties. I'm mostly interested in the ability to access data with SQL commands without having to install and maintain all the seperate database administration tools and packages on the windows platform. I'm interested in the "crossplatform-ness" because I run LabView on the Mac and Linux as well. As for access with ODBC, there are some ODBC drivers / wrappers for SQLite, but I haven't played with them yet. There are also some ADO drivers / wrappers for SQLite but I have had little success getting those to work in LabView, and of course they ruin the crossplatform idea since they are activeX based. I've created a CVI based DLL that can be called through LabView that lets you read and write to / from a SQLite database. This DLL simplifies the process of calling the SQLite DLL from LabView by taking care of some housekeeping and reformatting of data that are needed to make LabView happy.

My initial test case is a program that I am attempting to write to allow a user to load and crop a directory of images (JPG's) with a thumbnail display to let the user select the image they want to crop. I was thinking about processing the thumbnails once and loading them into a SQLite database as blob data to be retrieved the next time that directory is called up. I am also going to try and provide non-destructive editing by logging the crop parameters into the database and executing them only in an export step when the images get uploaded to a web page for viewing by the general public. I know some programs like this exist out there now, but they don't meet all the needs of my particular user, and thus I've been asked to research the idea to see if I can do it without breaking the bank.

Hope this provides a little more information.

Thanks,

Chris Davis

Link to comment
I've been working with SQLite 3 (www.sqlite.org) for the last couple of days. And had good success with and had some good success in developing a wrapper for SQLite that can easily be used in LabView. I'm writing this wrapper in LabWindows/CVI, but it is all standard ANSI C, and not very much of it anyway. I was wondering if there is a call for an embedded database like SQLite in the LabView world. I don't use databases very much but when I ran across an article about SQLite I couldn't resist toying with it. I have no problem posting the code, if there is interest, and I think it could prove to be a useful addition to the OpenG toolkit, if there was a call to develop it into a library compatable with OpenG. One nice thing is that SQLite is at least as cross-platform as LabView!

I await your responses!

Chris Davis

Chris: I think this is very interesting and worth developing into an OpenG project (we were actually discussing SQLite integration with LabVIEW, last week). We could build the shared library on all platforms and make it a cross-platform toolkit. I'm more than happy to help get it into the OpenG Toolkit. Send me a PM, and we can discuss.

Cheers,

Link to comment
I've created a CVI based DLL that can be called through LabView that lets you read and write to / from a SQLite database. This DLL simplifies the process of calling the SQLite DLL from LabView by taking care of some housekeeping and reformatting of data that are needed to make LabView happy.
Whould you be willing to post this DLL here so we could try it out?
Link to comment
G'day,

why not calling the sqlite3.dll directly? e.g.: sqlite.viDownload File:post-3293-1138210594.vi

Get your latest sqlite3.dll form www.sqlite.org. e.g. http://www.sqlite.org/sqlitedll-3_3_2.zip

Thomas

Thomas,

You can call that particular function directly from the SQLite DLL, but when I tried to interfact to it directly on some of the functions that actually execute SQL commands or deal with the database I crashed LV. I may be wrong, but I'm sure it will be easy to see when I've uploaded the interface code. I'll be through with my interface and example code soon and someone who has done this before can begin to look at what I've made and make it better. That's the idea behind open source isn't?

Thanks,

Chris

Link to comment

All,

I've worked a little on the LV SQLite Example I uploaded yesterday, and I found a much better function in SQLite to execute and retrieve all the data from a SQL statement. As such my DLL now has three functions exposed to the user, Open, Close, and Execute. Take a look at the reworked examples to see what I mean.

Chris

Download File:post-2547-1138317174.zip

Link to comment
All,

I've worked a little on the LV SQLite Example I uploaded yesterday, and I found a much better function in SQLite to execute and retrieve all the data from a SQL statement. As such my DLL now has three functions exposed to the user, Open, Close, and Execute. Take a look at the reworked examples to see what I mean.

Chris

first of all, nice job Chris, I think that this wrapper can be fairly useful, since sqlite3.dll makes lv8 think it's corrupting it's memory. :thumbup:

I've been playing around with your example, and one thing I noticed is that the memory usage continues to climb. Not sure where the memory leak is.

Run LV SQLite Read Database Into Table.vi in continuous mode, and you'll eventually run out of memory.

Link to comment
first of all, nice job Chris, I think that this wrapper can be fairly useful, since sqlite3.dll makes lv8 think it's corrupting it's memory. :thumbup:

I've been playing around with your example, and one thing I noticed is that the memory usage continues to climb. Not sure where the memory leak is.

Run LV SQLite Read Database Into Table.vi in continuous mode, and you'll eventually run out of memory.

I'll take a look today or this weekend to see if I can figure out what is going wrong and causing the memory leak. If I find it I'll upload another version.

The next step is to make a database with some blob data in it to see how to access that type of data easily. I'm thinking of a simple database with some JPG's in it to start with. That is my original use case for this particular project so I think I'll try doing something along those lines now. I'll have to find the memory leak first, since when you start working with Blob data, your memory usage goes up dramatically.

Chris

Link to comment
  • 2 weeks later...

I haven't had time to look at the code to solve the memory leak, but I have started an OpenG project to begin to make the LabView SQLite toolkit a reality. I've created a Requirements Document to state the project goals for those who want to be involved. This document is avaliable through the OpenG CVS system, so you'll have to check with Jim Kring if you want to be able to contribute to this project. I'm posting the first draft of the Requirements document here for everyone who was interested to review.

Chris Davis

Download File:post-2547-1139455457.doc

Link to comment
  • 2 years later...

QUOTE (chrisdavis @ Feb 9 2006, 04:24 AM)

I haven't had time to look at the code to solve the memory leak, but I have started an OpenG project to begin to make the LabView SQLite toolkit a reality. I've created a Requirements Document to state the project goals for those who want to be involved. This document is avaliable through the OpenG CVS system, so you'll have to check with Jim Kring if you want to be able to contribute to this project. I'm posting the first draft of the Requirements document here for everyone who was interested to review.

Chris Davis

For some reason, new records are inserted twice in the database when using the INSERT INTO command. Any idea what's wrong ?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.