Re: [sqlite] SQLite 3.2.5 and Mac OSX network folders
The Makefile has this line: include $(MAKEFILEPATH)/CoreOS/ReleaseControl/GNUSource.make so you will need the Darwin project CoreOSMakefiles-30. Working backwards, GNUSource.make includes Common.make, which defines OBJROOT to be /tmp/$(ProjectName)/Build. With this, I found the built products in: /tmp/SQLite3/Build/.libs/ The makefiles appear to be from a Project Builder makefile-based project (does Xcode still support these?). Any, I was able to build it outside of Xcode and it may work to create a project if you want. (I didn't actually install the built product, so there may be issues with that step.) Here's another suggestion for you. Obviously you are going to be interested in merging Apple's changes in with the latest SQLite source. Subversion (and probably other SCMs) has some ability to track a branch relative to a vendor distribution (i.e., the standard SQLite distribution), which would help combine Apple's changes and the changes from 3.1.3 to 3.2.5. I've never used that feature of Subversion, so I can't offer much more at the moment. Keep us posted, I'm curious to know how this goes for you. Aaron On Oct 28, 2005, at 11:36 AM, Steve Palmer wrote: Has anybody tried building that though? If you download the files from http://www.sqlite.org/cvstrac/tktview?tn=1240 and run make from the root of the expanded folder then it will go through the process of configuring and building, but I can't find the output files anywhere. A search under the folder shows nothing seems to have been created. Interestingly, if you build from the SQLite3 folder, it will generate the object files and place the libraries in a hidden .libs folder but those all omit the new locking mechanism and hence the final results don't work for me. Unfortunately I can't quite figure out what is different. Any ideas? - Steve On Oct 27, 2005, at 6:09am, Aaron Burghardt wrote: You can take a look at what Apple has done for OS X here: http://www.opensource.apple.com/darwinsource/10.4/SQLite-28/ Don't be mislead by the project name--it is SQLite 3. I haven't studied it closely, but it should allow you to build exactly what Apple shipped. The Makefile has references to locking callbacks, so this might be relevant: # add -DSQLITE_DEBUG=1 to enable lock tracing and other debugging features # you also need to set sqlite3_os_trace to 1 in SQLite3/src/ os_common.h Extra_CC_Flags += -DASSERT_VIA_CALLBACK=1 - DENABLE_LOCKING_CALLBACKS=1 HTH, Aaron On Oct 25, 2005, at 12:45 PM, Steve Palmer wrote: What are those reasons and is there any expectation that they can be made available as patches for folks who build SQLite privately? I cannot use the libsqlite3.dylib that comes with Mac OSX 10.4 since my application needs to run on 10.3.9 too and there is no equivalent static version that I can find. - Steve On Oct 25, 2005, at 4:57am, [EMAIL PROTECTED] wrote: Steve Palmer <[EMAIL PROTECTED]> wrote: I'm currently investigating a problem with my application, SQLite 3.2.5 and a database located on a Mac OSX Server network share that does not seem to repro with the SQLite 3.1.3 that ships with Mac OSX 4.1. Specifically if I place a SQLite database file on a folder on a remote network share and attempt to access it using the sqlite3 utility, I get different results. Apple added special hacks to their release of SQLite 3.1.3 that allow it to work on remote filesystems with broken file locking. For various reasons, those hacks have not been incorporated into the SQLite core, yet. -- D. Richard Hipp <[EMAIL PROTECTED]>
Re: [sqlite] Re: Number of rows in a query result
On Oct 28, 2005, at 7:20 PM, SRS wrote: Edward Wilson wrote: The idea of issuing two selects is, well, a hack, and knowing how many records one has in a result-set is a powerful feature Are you needing a progress bar for the search (ie the query?) Or some action based on the result set? If the later, get the result set as your favorite container.. ask the container the size. If its the first then a "feature" won't help. It still has to 'run' the query in order to get the count. It would be like me asking you to tell me how many red Skittles are in a package before you open it. As for being a 'hack' .. all your 'feature' would be is a pretty programming interface around that hack. As I said before, how can the database know the number of items that will be returned without first searching for them. I think the problem is not so much (at least IMHO) that two queries have to be performed (that itself is a reasonable expectation), but that the COUNT(*) query is likely to be slow because of the full table scan. One option is to use an aftermarket solution... for example, in my Perl applications once I have queried the db for the columns based on my criteria, I simply count the number of elements in my record set thereby avoiding a double query to the database. Although, in reality, I personally don't mind the COUNT(*) option... none of my databases are that large to merit worrying about this.
[sqlite] SQLite as a Windows kernel tool
I have been toying with the idea of checking whether or not I can use SQLite in a Windows device driver as its database. I am working on an existing product that is implemented as a series of Windows device drivers, filter drivers and even a file system driver. The file system driver manages a dedicated disk partition that contains an NTFS file system and a series of files (some flat files and some Btree files) that serve as the database. The code that manages this database is quite old and has been heavily modified several times, but the code is not well structured and contains a number of architectural features that act as hinderances to modifications and performance enhancements. From the beginning it was clear to me that several issues would be greatly minimized or even eliminated if we could use some form of a relational database management package instead of the home-grown file management code, but there do not seem to be any database packages that are available to kernel code. As part of another effort we looked at using SQLite, and performed a number of tests to that end. When I discovered that all of the source code was available, it seemed that we may be able to 'port' the code for use within out file system driver, either as a kernel DLL or directly compiled into the existing component. A number of features would have to be modified, such as the use of malloc() and free() calls, which would need to be replaced with the appropriate calls to kernel routines (if not the development of an extra set of routines for such dynamic memory usage), but we were hopeful. I had used the Visual C++ 6 compiler (in C mode) to compile the existing SQLite source for use in user space, and that was not much of a problem, but the DDK (kernel) compiler was a modified version of the Visual C++ 7 compiler, and a number of compilation features are quite different when compiling code into the kernel as opposed as into user space. We had a number of problems with compiling the SQLite code as part of our kernel build, and so I decided to attempt to compile the latest source code for user space using the Visual C++ 7 compiler (Visual Studio .Net 2003). I have an HTML file that is the output from this attempt, which lists 193 compiler warnings (the code actually runs) based on the 3.2.7 version of the SQLite source code. This mail list does not permit me to attach the file (message rejected as too large), but if anyone wants to see it I can send it to you. The vast majority of the warnings are related to either unsafe implicit data type conversions or signed and unsigned comparison operations. Some of these are not unreasonable, such as a complaint about conversion from "size_t" to "int", which should be the same size objects, but others definitely appear to be significant, such as an implicit conversion from "i64" or "u64" to int, which is a legitimate concern. Some of the signed/unsigned comparisons are also suspect (is an unsigned integer value of 0x81230001 greater than or less than a signed integer value of 0x0001? -- hint, as a signed value the former is a negative number, but as an unsigned it is not). Some of these warnings are simply the compiler being extremely (and appropriately) cautious, but some of them truly do look like odd coding. Why should the code unconditionally and implicitly assign a 64-bit integer value into a 32-bit integer variable? If the conditions under which this is done are such that there can be no loss of data, then there should be a comment explaining this, and the cast should be explicit to enforce that this is expected. Unfortunately, there are no such comments and not all of the implicit casts have a clear context when simply examining isolated lines of code. I had a quick look at some of the code, but I am not certain whether all, or even most, of these warnings can be safely ignored or not. I tried modifying the code to add explicit casts to eliminate all of the warnings, which worked, but I do not know whether or not the resulting code contains runtime errors or not (specifically as a result of data loss at runtime or improper comparison logic). Could someone have a look at some of these and provide some opinions? I know that the coding style used for SQLite is what I have heard referred to as "minimal C", but should the code not be commented concerning such conversions, and the conversion be made explicit? -ken
Re: [sqlite] Re: Number of rows in a query result
Edward Wilson wrote: The idea of issuing two selects is, well, a hack, and knowing how many records one has in a result-set is a powerful feature Are you needing a progress bar for the search (ie the query?) Or some action based on the result set? If the later, get the result set as your favorite container.. ask the container the size. If its the first then a "feature" won't help. It still has to 'run' the query in order to get the count. It would be like me asking you to tell me how many red Skittles are in a package before you open it. As for being a 'hack' .. all your 'feature' would be is a pretty programming interface around that hack. As I said before, how can the database know the number of items that will be returned without first searching for them.
Re: [sqlite] Re: Re: Number of rows in a query result
Igor puts it very clearly. No DBMS knows how many rows are in a selection until the selection has been performed. Therefore you cannot do a progress bar since the selection is complete before you have the necessary information to build the bar. The answer is to use some other form of progress indicator, such as a running count, a running man or even a running Duke etc. Performing two SELECTs is rather pointless unless the progress bar is meant to present the progress of post-SELECT processing which is very much slower than the actual SELECT. One of the nice feature of Sqlite is it's callback and step functions so that it is not necessary to store any results, permitting the building of robust programs which cannot hit local storage limits and fail. JS Igor Tandetnik wrote: Edward Wilson wrote: This is really an important feature to have, I am surprised it's not already there. I too have had the same question but have just never asked. Well, if the golden standard is mysql_num_rows, consider the following bit in the documentation: The use of mysql_num_rows() depends on whether you use mysql_store_result() or mysql_use_result() to return the result set. If you use mysql_store_result(), mysql_num_rows() may be called immediately. If you use mysql_use_result(), mysql_num_rows() does not return the correct value until all the rows in the result set have been retrieved. mysql_store_result is essentially equivalent to sqlite3_get_table - it does not return until all rows are retrieved and stored in memory. Note that sqlite3_get_table does return the number of rows. Of course it is pretty useless for the purpose of providing progress indication. mysql_use_result is equivalent to calling sqlite3_step in a loop - and just as in SQLite, MySQL cannot return the row count until all rows are fetched. Well, SQLite does not provide the row count in this case either, but you can easily maintain your own counter. Again, this does not help much with progress indicator. The idea of issuing two selects is, well, a hack, and knowing how many records one has in a result-set is a powerful feature. The fundamental problem is that, for many queries, counting all rows is actually as complex a task as retrieving them in the first place. This is a property of SQL language and relational data model in general, it's not specific to SQLite or any other engine. There is no way around it. Igor Tandetnik
[sqlite] Re: Re: Number of rows in a query result
Edward Wilson wrote: This is really an important feature to have, I am surprised it's not already there. I too have had the same question but have just never asked. Well, if the golden standard is mysql_num_rows, consider the following bit in the documentation: The use of mysql_num_rows() depends on whether you use mysql_store_result() or mysql_use_result() to return the result set. If you use mysql_store_result(), mysql_num_rows() may be called immediately. If you use mysql_use_result(), mysql_num_rows() does not return the correct value until all the rows in the result set have been retrieved. mysql_store_result is essentially equivalent to sqlite3_get_table - it does not return until all rows are retrieved and stored in memory. Note that sqlite3_get_table does return the number of rows. Of course it is pretty useless for the purpose of providing progress indication. mysql_use_result is equivalent to calling sqlite3_step in a loop - and just as in SQLite, MySQL cannot return the row count until all rows are fetched. Well, SQLite does not provide the row count in this case either, but you can easily maintain your own counter. Again, this does not help much with progress indicator. The idea of issuing two selects is, well, a hack, and knowing how many records one has in a result-set is a powerful feature. The fundamental problem is that, for many queries, counting all rows is actually as complex a task as retrieving them in the first place. This is a property of SQL language and relational data model in general, it's not specific to SQLite or any other engine. There is no way around it. Igor Tandetnik
Re: [sqlite] basic question about sqlite
It would be safe and efficient provided that you did not have a massive load with many processes expecting simultaneous access. Just be careful that your applications can gracefully handle the occasional lock state and use transactions carefully. Don't design in queries which have a long execution time. It is called "..lite" for a good reason. JS Dave Dyer wrote: If I designed a sqlite database to be used by a bunch of independent applications, for example a bunch of CGI scripts each of which opened the database, did some processing, and exited, would that be (a) safe (b) effecient ?
Re: [sqlite] built-in functrion suggestion: size of blob
--- Nuno Lucas <[EMAIL PROTECTED]> wrote: > On 10/25/05, Joe Wilson <[EMAIL PROTECTED]> wrote: > > The built-in Sqlite length() function works just fine on blobs: > > > > sqlite> select length(X'00'); > > 5 > > > > Why do you think it doesn't? > > I remember a few months ago noticing it would count UTF-8 chars, not > bytes, so it would not return the right length for blobs in all cases > (a '\0' is a valid UTF-8 char, but try with the '(c)' [copyright] sign, > which is 2 bytes). > > I don't have the code in front of me, and can be just my memory, but I > don't see that behaviour changing or would break a lot of SQL during > normal text manipulation. > > Regards, > ~Nuno Lucas You are mistaken. Text and blobs are different. TEXT is of type "SQLITE_TEXT". BLOB is of type "SQLITE_BLOB". length() has always correctly returned the size of a blob - look at the code: /* ** Implementation of the length() function */ static void lengthFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ int len; assert( argc==1 ); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_BLOB: case SQLITE_INTEGER: case SQLITE_FLOAT: { sqlite3_result_int(context, sqlite3_value_bytes(argv[0])); break; } case SQLITE_TEXT: { const char *z = sqlite3_value_text(argv[0]); for(len=0; *z; z++){ if( (0xc0&*z)!=0x80 ) len++; } sqlite3_result_int(context, len); break; } default: { sqlite3_result_null(context); break; } } } __ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs
[sqlite] Impossible to open or create database phpsla.sqlite
Hi, i am a user on following machine: -- Machine hardware: sun4u OS version: 5.8 Processor type: sparc Hardware: SUNW,Sun-Fire-880 The following components are installed on your system: Sun Studio 10 Sun Studio 10 C Compiler Sun Studio 10 C++ Compiler Sun Studio 10 Tools.h++ 7.1 Sun Studio 10 C++ Standard 64-bit Class Library Sun Studio 10 Garbage Collector Sun Studio 10 Fortran 95 Sun Studio 10 Debugging Tools (including dbx) Sun Studio 10 Debugger GUI Sun Studio 10 Performance Analyzer (including collect, ...) Sun Studio 10 X-Designer Sun Studio 10 VIM editor Sun Studio 10 XEmacs editor Sun Studio 10 Native Connector Tool Sun Studio 10 LockLint Sun Studio 10 Building Software (including dmake) Sun Studio 10 Documentation Set version of "/opt/SUNWspro/bin/../prod/bin/../../bin/cc": Sun C 5.7 Patch 117836-03 2005/05/11 version of "/opt/SUNWspro/bin/../prod/bin/../../bin/CC": Sun C++ 5.7 Patch 117830-02 2005/03/30 version of "/opt/SUNWspro/bin/../prod/bin/../../bin/f90": Sun Fortran 95 8.1 Patch 117834-02 2005/03/30 version of "/opt/SUNWspro/bin/../prod/bin/../../bin/dbx": Sun Dbx Debugger 7.4 117844-02 2005/07/15 version of "/opt/SUNWspro/bin/../prod/bin/../../bin/analyzer": Sun Performance Analyzer 7.4 2005/01/07 version of "/opt/SUNWspro/bin/../prod/bin/../../bin/dmake": Sun Distributed Make 7.6 117838-01 2005/03/04 -- Now I have a problem. I work with the latest release of XAMPP for Solaris and everything worked fine until this morning. Now I have the problem, when I try to open or use the SQLite database, the following error-message appears: "Impossible to open or create database phpsla.sqlite". I tried to uninstall the complete XAMPP-package, but when reinstalling it, I got the same problem again (even if it was installed in a different directory). The "phpsla.sqlite" does exist and it is about 7kB big. It is the standard that comes with the XAMPP-package. Can anyone help me with this problem? I am not the administrator of this machine, so the apache and the mysql servers run on different ports as the standards are set (8497 instead of 80, 84979 instead of 3306). I can access the mysql-configuration-site from the internet, but i am not able to open the phpsqliteadmin-routine. Even when I open sqlite by typing "sqlite phpsla.sqlite" and then trying to read out of the database file with "read phpsla.sqlite", the same error raises. So can you give me a hint, how to solve this problem? Thanks in advance, Peter
Re: [sqlite] Dotnet C# support
I agree, never use PInvoke, if possible to avoid There is a performqncepenalty, and maybe you loose platform-independency (think of Mono) Bert > I think you are looking for this http://adodotnetsqlite.sourceforge.net/ > > I wrote my own driver in C++ (boy, that was a lot of work) then discovered > the above. > > - > ed > > --- Wilfried Mestdagh <[EMAIL PROTECTED]> wrote: > >> Hi Darren, >> >> > Is there a version which will work for dotnot? >> >> If not then you can use every win32 dll in C# using P/Invoke >> >> --- >> Rgds, Wilfried >> http://www.mestdagh.biz >> >> > > > > > > __ > Yahoo! Mail - PC Magazine Editors' Choice 2005 > http://mail.yahoo.com >
Re: [sqlite] basic question about sqlite
On 10/28/05, Dave Dyer <[EMAIL PROTECTED]> wrote: > > If I designed a sqlite database to be used by a bunch of independent > applications, for example a bunch of CGI scripts each of which > opened the database, did some processing, and exited, would > that be (a) safe (b) effecient ? As long as you check the return codes, which might indicate if you have conflicts, it should work just fine. That's exactly what I did with it. It works fine and is quite speedy. You might consider fast cgi if your web server supports it.
[sqlite] basic question about sqlite
If I designed a sqlite database to be used by a bunch of independent applications, for example a bunch of CGI scripts each of which opened the database, did some processing, and exited, would that be (a) safe (b) effecient ?
Re: [sqlite] Re: Number of rows in a query result
Sqlite-Kernel-Hackers: This is really an important feature to have, I am surprised it's not already there. I too have had the same question but have just never asked. btw, is this by any chance on the feature road-map? The idea of issuing two selects is, well, a hack, and knowing how many records one has in a result-set is a powerful feature. - ed __ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com
Re: [sqlite] Dotnet C# support
I think you are looking for this http://adodotnetsqlite.sourceforge.net/ I wrote my own driver in C++ (boy, that was a lot of work) then discovered the above. - ed --- Wilfried Mestdagh <[EMAIL PROTECTED]> wrote: > Hi Darren, > > > Is there a version which will work for dotnot? > > If not then you can use every win32 dll in C# using P/Invoke > > --- > Rgds, Wilfried > http://www.mestdagh.biz > > __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
RE: [sqlite] Re: Number of rows in a query result
If by handheld you mean PocketPCs, then: http://sqlite-wince.sourceforge.net/. The database file itself stays the same. If you want Palm support, you'll be a lot harder pressed to find anything. Eric Pankoke Founder Point Of Light Software http://www.polsoftware.com/ -Original Message- From: vidushi tandon [mailto:[EMAIL PROTECTED] Sent: Friday, October 28, 2005 1:09 AM To: sqlite-users@sqlite.org Subject: Re: [sqlite] Re: Number of rows in a query result hi all can anyone tell me how to port sqlite databases to the handheld devices rgds vidushi tandon --- Dennis Cote <[EMAIL PROTECTED]> wrote: > Puneet Kishor wrote: > > > Igor Tandetnik wrote: > > > >> Alfredo Cole > <[EMAIL PROTECTED]> wrote: > >> > >>> In order to update a progress bar, I need to > know the total number of > >>> rows returned by a query, similar to MySQL's > mysql_num_rows. Is there > >>> a function like that in the C API? I may have > overlooked it, but have > >>> not found it so far. > >> > >> > >> There is no such function. Most of the time, > SQLite does not know how > >> many rows there are in the resultset until they > are all actually > >> retrieved. It just produces rows one by one as it > finds them. > >> > >> The only way I know to achieve what you want is > to run the query > >> twice, first as "select count(*)" to obtain the > count, then again > >> with the desired column list. Depending on the > query, "select > >> count(*)" may take as long as the full query, and > in some rare cases > >> it may even be slower. Bottom line, it is > impractical to try and > >> produce an accurate progress indicator for SQLite > queries. > > > > > > > > one suggestion has been to create another table > with a single row > > holding the number of rows in your table of > interest. Just query that > > one table for its one value. > > > > Use TRIGGERs on INSERT, UPDATE, and DELETE to > automatically adjust > > the value in the table with the row count. > > > > > This only works if your select query is returning > all the records in the > table. If you use where conditions to select a > subset of the rows this > will fail because any query could return a number of > rows that won't > match your carefully maintained count. > __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
Re: [sqlite] Dotnet C# support
thx for your response !! Robert Simpson a écrit : - Original Message - From: "Gregory Letellier" <[EMAIL PROTECTED]> i'm trying tu use sqli3 with vb. net he create the db but not the table.. what is the mistake ? i've this code Imports System.Runtime.InteropServices Public Class Form1_ Public Structure sqlite_callback Public Void As Long Public I1 As Long Public s1 As String Public s2 As String End Structure Public Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal Filename As String, ByRef Handle As Long) As Long Public Declare Function sqlite3_exec Lib "sqlite3.dll" (ByVal Handle As Long, ByVal Query As String, ByRef CallbackFunction As sqlite_callback, ByRef CallBackArgs As Long, ByRef Erreur As String) As Long Public Declare Function sqlite3_close Lib "sqlite3.dll" (ByVal Handle As Long) As Long Public Declare Function sqlite3_errmsg Lib "sqlite3.dll" (ByVal Handle As Long) As String Public Sub Main() Dim lRet As Long Dim lHandle As Long Dim sErreur As String Dim sSQL As String lRet = sqlite3_open("c:\test.db", lHandle) sSQL = "CREATE Table Toto(titi varchar(15));" lRet = sqlite3_exec(lHandle, sSQL, Nothing, Nothing, sErreur) sqlite3_close(lHandle) End Sub End Class Lots of problems here ... My VB is rusty, but here goes: 1. Don't bother declaring the callback struct -- you cannot do any form of callbacks in .NET with SQLite without major hacking. SQLite's callbacks are expected to be "cdecl" and .NET callbacks are always "stdcall" and you will get stack errors if you even attempt it. The ADO.NET 2.0 provider for SQLite does it, but I had to go through hoops. 2. sqlite3_exec is declared incorrectly. The errormessage is a char **, which is a pointer to a pointer. Getting this out of sqlite into .NET is not straightforward. You'll have to use ByRef IntPtr and use the Marshal class to convert it to a string. 3. sqlite3_open and sqlite3_exec are both sortof declared and processed incorrectly. Those functions expect UTF-8 encoded strings, and you are passing "string" to them which .NET will at best translate to MBCS ANSI strings -- which means no international support. For added safety you should declare those API functions with the CharSet=ANSI attribute to make absolutely sure .NET gives sqlite ANSI strings instead of UNICODE strings. It's still wrong, but its close enough for English-only. 4. All sqlite API functions are declared as cdecl, and without instructions to the contrary, .NET will try and call them as stdcall which means after every call .NET will have to perform stack fixups. It won't error out your program per-se, but it will be a performance hit. There's an attribute you can use to change the calling conventions of the API declaration, but I can't remember it off the top of my head. Robert
Re: [sqlite] Dotnet C# support
- Original Message - From: "Gregory Letellier" <[EMAIL PROTECTED]> i'm trying tu use sqli3 with vb. net he create the db but not the table.. what is the mistake ? i've this code Imports System.Runtime.InteropServices Public Class Form1_ Public Structure sqlite_callback Public Void As Long Public I1 As Long Public s1 As String Public s2 As String End Structure Public Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal Filename As String, ByRef Handle As Long) As Long Public Declare Function sqlite3_exec Lib "sqlite3.dll" (ByVal Handle As Long, ByVal Query As String, ByRef CallbackFunction As sqlite_callback, ByRef CallBackArgs As Long, ByRef Erreur As String) As Long Public Declare Function sqlite3_close Lib "sqlite3.dll" (ByVal Handle As Long) As Long Public Declare Function sqlite3_errmsg Lib "sqlite3.dll" (ByVal Handle As Long) As String Public Sub Main() Dim lRet As Long Dim lHandle As Long Dim sErreur As String Dim sSQL As String lRet = sqlite3_open("c:\test.db", lHandle) sSQL = "CREATE Table Toto(titi varchar(15));" lRet = sqlite3_exec(lHandle, sSQL, Nothing, Nothing, sErreur) sqlite3_close(lHandle) End Sub End Class Lots of problems here ... My VB is rusty, but here goes: 1. Don't bother declaring the callback struct -- you cannot do any form of callbacks in .NET with SQLite without major hacking. SQLite's callbacks are expected to be "cdecl" and .NET callbacks are always "stdcall" and you will get stack errors if you even attempt it. The ADO.NET 2.0 provider for SQLite does it, but I had to go through hoops. 2. sqlite3_exec is declared incorrectly. The errormessage is a char **, which is a pointer to a pointer. Getting this out of sqlite into .NET is not straightforward. You'll have to use ByRef IntPtr and use the Marshal class to convert it to a string. 3. sqlite3_open and sqlite3_exec are both sortof declared and processed incorrectly. Those functions expect UTF-8 encoded strings, and you are passing "string" to them which .NET will at best translate to MBCS ANSI strings -- which means no international support. For added safety you should declare those API functions with the CharSet=ANSI attribute to make absolutely sure .NET gives sqlite ANSI strings instead of UNICODE strings. It's still wrong, but its close enough for English-only. 4. All sqlite API functions are declared as cdecl, and without instructions to the contrary, .NET will try and call them as stdcall which means after every call .NET will have to perform stack fixups. It won't error out your program per-se, but it will be a performance hit. There's an attribute you can use to change the calling conventions of the API declaration, but I can't remember it off the top of my head. Robert
Re: [sqlite] Dotnet C# support
- Original Message - From: "Darren Lodge" <[EMAIL PROTECTED]> Hi there, Is there a version which will work for dotnot? The WIKI page is the best place to look ... There are probably half a dozen providers for SQLite. Two ADO.NET providers (for ADO.NET 1.1 and ADO.NET 2.0) and several non-ADO.NET providers designed to be more streamlined. Robert
RE: [sqlite] Dotnet C# support
Original Message From: Darren Lodge [mailto:[EMAIL PROTECTED] Sent: Friday, October 28, 2005 4:01 AM To: sqlite-users@sqlite.org Subject: [sqlite] Dotnet C# support > Hi there, > > Is there a version which will work for dotnot? > > Darren Lodge > Software Engineer > CAP > > 0113 222 2058 (direct) > 0113 222 2000 (switchboard) > 0113 222 2001 (fax) http://docs.codehaus.org/display/BOO/SQLite+Database reid
RE: [sqlite] Dotnet C# support
Original Message From: Darren Lodge [mailto:[EMAIL PROTECTED] Sent: Friday, October 28, 2005 4:01 AM To: sqlite-users@sqlite.org Subject: [sqlite] Dotnet C# support > Hi there, > > Is there a version which will work for dotnot? > > Darren Lodge > Software Engineer > CAP > > 0113 222 2058 (direct) > 0113 222 2000 (switchboard) > 0113 222 2001 (fax) http://sourceforge.net/projects/adodotnetsqlite http://www.phpguru.org/static/SQLite.NET.html reid
Re: [sqlite] Dotnet C# support
Darren Lodge said: > Hi there, > > Is there a version which will work for dotnot? I've had good luck with some of the ADO.NET providers. They work pretty much like other ADO.NET providers. It's been a year or more so I can't say exactly how long ago it was, but I was reasonably happy with the result. Fair warning though that I'm not exactly a .NET power user, so what was acceptable to me may be a steaming pile to you. Clay Dowling -- Simple Content Management http://www.ceamus.com
Re: [sqlite] Dotnet C# support
I've used the C# .net provider for SQLite quite a bit. You can use SQL3 with these providers, you just have to add something to the connection string to tell the driver which version you're using and also the text encoding (UTF8Encoding=true;Version=3;). To create a new database, you just have to add the "New=True" key/value pair to the connection string. Here are some links to get you started: Microsoft.Net 1.x ADO.Net Provider http://sourceforge.net/projects/adodotnetsqlite Here's some sample code: --- SQLiteConnection Conn = new SQLiteConnection(); Conn.ConnectionString = "Data Source=diary.db;New=True;Compress=True;Synchronous=Off"; Conn.Open(); SQLiteCommand Cmd = new SQLiteCommand(); Cmd = Conn.CreateCommand(); Cmd.CommandText = "CREATE TABLE GOALS(GOALS_ID integer primary key , CATEGORY varchar (50), PRIORITY integer , SUBJECT varchar (150) , DESCRIPTION varchar (500),START_DATE datetime , COMPLETION_DATE datetime)" ; Cmd.ExecuteNonQuery(); Cmd.CommandText="CREATE TABLE NOTES (NOTES_ID integer primary key ,NOTES_DATE datetime ,NOTES_TEXT varchar (8000) )"; Cmd.ExecuteNonQuery(); Cmd.CommandText =" CREATE TABLE REMINDERS (REMINDER_ID integer primary key ,REMINDER_DATE smalldatetime ,SUBJECT varchar (150) ,DESCRIPTION varchar (500) , ALARM1_DATE datetime ,ALARM2_DATE datetime ,ALARM3_DATE datetime ,EMAIL_ALARM bit )"; Cmd.ExecuteNonQuery(); Cmd.CommandText ="CREATE TABLE TODO ( TODO_ID integer primary key,CATEGORY varchar (20),PRIORITY int, PERCENT_COMPLETE float, START_DATE datetime ,END_DATE datetime , SUBJECT varchar (150) , DETAILS varchar (8000) "; Cmd.ExecuteNonQuery(); Cmd.CommandText ="CREATE TABLE CATEGORIES (CATEGORY_ID INTEGER PRIMARY KEY,CATEGORY_NAME varchar (25))"; Cmd.ExecuteNonQuery(); Cmd.Dispose(); Conn.Close(); - There is also a new .net 2.0 provider: Microsoft.Net 2.0 ADO.Net Provider http://sourceforge.net/projects/sqlite-dotnet2 Gregory Letellier wrote: i'm trying tu use sqli3 with vb. net he create the db but not the table.. what is the mistake ? i've this code Imports System.Runtime.InteropServices Public Class Form1_ Public Structure sqlite_callback Public Void As Long Public I1 As Long Public s1 As String Public s2 As String End Structure Public Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal Filename As String, ByRef Handle As Long) As Long Public Declare Function sqlite3_exec Lib "sqlite3.dll" (ByVal Handle As Long, ByVal Query As String, ByRef CallbackFunction As sqlite_callback, ByRef CallBackArgs As Long, ByRef Erreur As String) As Long Public Declare Function sqlite3_close Lib "sqlite3.dll" (ByVal Handle As Long) As Long Public Declare Function sqlite3_errmsg Lib "sqlite3.dll" (ByVal Handle As Long) As String Public Sub Main() Dim lRet As Long Dim lHandle As Long Dim sErreur As String Dim sSQL As String lRet = sqlite3_open("c:\test.db", lHandle) sSQL = "CREATE Table Toto(titi varchar(15));" lRet = sqlite3_exec(lHandle, sSQL, Nothing, Nothing, sErreur) sqlite3_close(lHandle) End Sub End Class Darren Lodge a écrit : Thankyou! Darren Lodge Software Engineer CAP 0113 222 2058 (direct) 0113 222 2000 (switchboard) 0113 222 2001 (fax) -Original Message- From: Peter Berkenbosch [mailto:[EMAIL PROTECTED] Sent: 28 October 2005 09:19 To: sqlite-users@sqlite.org Subject: Re: [sqlite] Dotnet C# support -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Sigh.. http://www.google.com/search?hl=nl=SQLite+C%23=Google+zoeken = Darren Lodge wrote: Hi there, Is there a version which will work for dotnot? Darren Lodge Software Engineer CAP 0113 222 2058 (direct) 0113 222 2000 (switchboard) 0113 222 2001 (fax) - -- +---+--+ : Peter Berkenbosch: : :: t: +31 (0) 64 84 61653 : : PeRo ICT Solutions: f: +31 (0) 84 22 09880 : : Koemaad 26: m: [EMAIL PROTECTED] : : 8431 TM Oosterwolde: w: www.pero-ict.nl : +---+--+ : OpenPGP 0x0F655F0D (random.sks.keyserver.penguin.de) : +--+ -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.1 (MingW32) iD8DBQFDYd7g9bwznA9lXw0RAnb4AJ9oRUkvbXX5aX0HhXZEl6Lv4KNPyACgiUrq yXTEUWDFVPk97iM5u14V1B4= =0ECQ -END PGP SIGNATURE-
Re: [sqlite] Dotnet C# support
i'm trying tu use sqli3 with vb. net he create the db but not the table.. what is the mistake ? i've this code Imports System.Runtime.InteropServices Public Class Form1_ Public Structure sqlite_callback Public Void As Long Public I1 As Long Public s1 As String Public s2 As String End Structure Public Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal Filename As String, ByRef Handle As Long) As Long Public Declare Function sqlite3_exec Lib "sqlite3.dll" (ByVal Handle As Long, ByVal Query As String, ByRef CallbackFunction As sqlite_callback, ByRef CallBackArgs As Long, ByRef Erreur As String) As Long Public Declare Function sqlite3_close Lib "sqlite3.dll" (ByVal Handle As Long) As Long Public Declare Function sqlite3_errmsg Lib "sqlite3.dll" (ByVal Handle As Long) As String Public Sub Main() Dim lRet As Long Dim lHandle As Long Dim sErreur As String Dim sSQL As String lRet = sqlite3_open("c:\test.db", lHandle) sSQL = "CREATE Table Toto(titi varchar(15));" lRet = sqlite3_exec(lHandle, sSQL, Nothing, Nothing, sErreur) sqlite3_close(lHandle) End Sub End Class Darren Lodge a écrit : Thankyou! Darren Lodge Software Engineer CAP 0113 222 2058 (direct) 0113 222 2000 (switchboard) 0113 222 2001 (fax) -Original Message- From: Peter Berkenbosch [mailto:[EMAIL PROTECTED] Sent: 28 October 2005 09:19 To: sqlite-users@sqlite.org Subject: Re: [sqlite] Dotnet C# support -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Sigh.. http://www.google.com/search?hl=nl=SQLite+C%23=Google+zoeken = Darren Lodge wrote: Hi there, Is there a version which will work for dotnot? Darren Lodge Software Engineer CAP 0113 222 2058 (direct) 0113 222 2000 (switchboard) 0113 222 2001 (fax) - -- +---+--+ : Peter Berkenbosch : : : : t: +31 (0) 64 84 61653 : : PeRo ICT Solutions: f: +31 (0) 84 22 09880 : : Koemaad 26: m: [EMAIL PROTECTED] : : 8431 TM Oosterwolde : w: www.pero-ict.nl : +---+--+ : OpenPGP 0x0F655F0D (random.sks.keyserver.penguin.de) : +--+ -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.1 (MingW32) iD8DBQFDYd7g9bwznA9lXw0RAnb4AJ9oRUkvbXX5aX0HhXZEl6Lv4KNPyACgiUrq yXTEUWDFVPk97iM5u14V1B4= =0ECQ -END PGP SIGNATURE-
RE: [sqlite] Dotnet C# support
Thankyou! Darren Lodge Software Engineer CAP 0113 222 2058 (direct) 0113 222 2000 (switchboard) 0113 222 2001 (fax) -Original Message- From: Peter Berkenbosch [mailto:[EMAIL PROTECTED] Sent: 28 October 2005 09:19 To: sqlite-users@sqlite.org Subject: Re: [sqlite] Dotnet C# support -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Sigh.. http://www.google.com/search?hl=nl=SQLite+C%23=Google+zoeken = Darren Lodge wrote: > Hi there, > > Is there a version which will work for dotnot? > > Darren Lodge > Software Engineer > CAP > > 0113 222 2058 (direct) > 0113 222 2000 (switchboard) > 0113 222 2001 (fax) > > - -- +---+--+ : Peter Berkenbosch : : : : t: +31 (0) 64 84 61653 : : PeRo ICT Solutions: f: +31 (0) 84 22 09880 : : Koemaad 26: m: [EMAIL PROTECTED] : : 8431 TM Oosterwolde : w: www.pero-ict.nl : +---+--+ : OpenPGP 0x0F655F0D (random.sks.keyserver.penguin.de) : +--+ -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.1 (MingW32) iD8DBQFDYd7g9bwznA9lXw0RAnb4AJ9oRUkvbXX5aX0HhXZEl6Lv4KNPyACgiUrq yXTEUWDFVPk97iM5u14V1B4= =0ECQ -END PGP SIGNATURE-
Re: [sqlite] Dotnet C# support
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Sigh.. http://www.google.com/search?hl=nl=SQLite+C%23=Google+zoeken= Darren Lodge wrote: > Hi there, > > Is there a version which will work for dotnot? > > Darren Lodge > Software Engineer > CAP > > 0113 222 2058 (direct) > 0113 222 2000 (switchboard) > 0113 222 2001 (fax) > > - -- +---+--+ : Peter Berkenbosch : : : : t: +31 (0) 64 84 61653 : : PeRo ICT Solutions: f: +31 (0) 84 22 09880 : : Koemaad 26: m: [EMAIL PROTECTED] : : 8431 TM Oosterwolde : w: www.pero-ict.nl : +---+--+ : OpenPGP 0x0F655F0D (random.sks.keyserver.penguin.de) : +--+ -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.1 (MingW32) iD8DBQFDYd7g9bwznA9lXw0RAnb4AJ9oRUkvbXX5aX0HhXZEl6Lv4KNPyACgiUrq yXTEUWDFVPk97iM5u14V1B4= =0ECQ -END PGP SIGNATURE-
Re: [sqlite] Dotnet C# support
Hi Darren, > Is there a version which will work for dotnot? If not then you can use every win32 dll in C# using P/Invoke --- Rgds, Wilfried http://www.mestdagh.biz
[sqlite] Dotnet C# support
Hi there, Is there a version which will work for dotnot? Darren Lodge Software Engineer CAP 0113 222 2058 (direct) 0113 222 2000 (switchboard) 0113 222 2001 (fax)