Re: [sqlite] How do I backup sqlite data file
sqliteX active.db .dump > backup.sql Koji Namekata wrote: Hi, What is the most reasonable way to backup sqlite data file? When applications using that db file are stopped, simple file copy `cp active.db backup.db' works fine. But with long running applications, is it correct to assume asynchronous copy may result in inconsitent state of the db file, and if so, how do I backup it? Thanks in advance. -- Namekata Koji
Re: AW: [sqlite] VB6 question
I am using SQLite Plus sucessfully Ray Borror Gregory Letellier <[EMAIL PROTECTED]> wrote: all the wrapper ar for 2.8 and i wan't use the 3.0 anyone known 3.0 wrapper ? Steve O'Hara a écrit : >Don't want to dampen your enthusiasm for this route but. why do you >think there are so many VB wrappers for SQLite? > >It's because you can't use the SQLite DLL directly from VB - some functions >will work but the essential ones won't. It's because the DLL returns things >like pointers to arrays of pointers which is not very groovy in VB (in fact, >you would have to resort to some OS calls to unravel that). > >Use one of the wrappers. > >Steve > > > > > > >-Original Message- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] >rg]On Behalf Of Gregory Letellier >Sent: 27 July 2005 11:17 >To: sqlite-users@sqlite.org >Subject: Re: AW: [sqlite] VB6 question > > >Ok Thank's for your help i will trying this !!! > >[EMAIL PROTECTED] a écrit : > > > >>Hi, >> >>unfortunately this has to do with the C calling convention used by >> >> >sqlite3.dll. By default DLLs compiled with C have the cdecl calling >convention, but VB only supports the stdcall calling convention. > > >>You must recompile sqlite using MS Visual C++ or other compiler and switch >> >> >the default calling convention from cdecl to stdcall in the compiler/linker >settings. > > >>HTH >>Michael >> >> >> >> >> >>>hello i'm trying to open a database with VB6 without wrapper >>> >>>i'm using sqlite3.dll >>> >>>and it's my code : >>> >>>Option Explicit >>>Private Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal filename >>>As String, ByRef dbHandle As Long) As Long >>>Private Declare Function sqlite3_open16 Lib "sqlite3.dll" (ByVal >>>filename As String, ByRef dbHandle As Long) As Long >>>Private Declare Sub sqlite3_close Lib "sqlite3.dll" (ByVal DB_Handle As >>>Long) >>> >>>Private Sub Form_Load() >>> Dim lRet As Long >>> Dim lDbHandle As Long >>> Dim sFilename As String >>> >>> sFilename = "c:\toto.db" >>> sqlite3_open sFilename, lDbHandle >>> MsgBox ("lRet=" & lRet) >>> MsgBox ("ldbhandle=" & lDbHandle) >>> sqlite3_close (lDbHandle) >>>End Sub >>> >>>when i launch it, i've an error 49 : Bad DLL calling convention >>> >>>anyone can help me ? where is my fault ? >>> >>>thx >>>Gregory Letellier >>> >>> >>> >>> >>> >>> >> >> >> >> > > > > > > >
[sqlite] Quick start example contains possible memory leak: zErrMsg
I believe the following quick start example contains a possible memory leak. This is the program found at the following link: http://www.sqlite.org/quickstart.html The error can be reproduced by compiling the example and running it for the following SQL statement: ./a.out tmptable "drop table junk" Since the table "junk" does not exist, zErrMsg is first allocated memory (legacy.c:129) in the statement below: /src/legacy.c (line 129) if( rc!=SQLITE_OK && rc==sqlite3_errcode(db) && pzErrMsg ){ *pzErrMsg = malloc(1+strlen(sqlite3_errmsg(db))); However, it appears that this memory is not freed. Not even in sqlite3_close(db). Shown below the valgrind statement and the report. valgrind --logfile=valgrind.output --leak-check=yes --tool=memcheck ./a.out tmptable "drop table junk" ==31665== LEAK SUMMARY: ==31665==definitely lost: 20 bytes in 1 blocks. ==31665==possibly lost: 0 bytes in 0 blocks. ==31665==still reachable: 128 bytes in 2 blocks. ==31665== suppressed: 0 bytes in 0 blocks. ==31665== Reachable blocks (those to which a pointer was found) are not shown. ==31665== To see them, rerun with: --show-reachable=yes FIX: rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg); if( rc!=SQLITE_OK ){ fprintf(stderr, "SQL error: %s\n", zErrMsg); /* This will free zErrMsg if assigned */ if (zErrMsg) free(zErrMsg); } After making the following change, valgrind reports no memory leaks. Why It My Be Relevant: Some SQL commands seemed to be ignored by design. For example, SQLite can indirectly support the "DROP TABLE IF EXIST junk" by executing the "drop table junk" and ignoring the error. However, when there are many such statements, with long running programs, the memory is never freed. At least I believe it is not. If the above is correct, changing the example my help users. Regards, Mike Chirico #include #include static int callback(void *NotUsed, int argc, char **argv, char **azColName){ int i; for(i=0; i
Re: [sqlite] How to get the size of the value
Dennis Cote wrote: Shawn Walker wrote: How do I determine the size of the value of the string/blob that is in the database? I would like to know how big the data so that I can determine how to handle the data if it's a large data so that I can put the data in a file instead of in memory. Shawn, You can use the sqlite3_column_bytes() API function to get the size of a string or blob, but by the time you can do this (i.e. after calling sqlite3_step()) it is already in memory and ready to be returned to you using sqlite3_column_blob() or sqlite3_column_text(). These functions return pointers to the buffer that holds the blob or string. You could perhaps use this to copy each individual blob to a file so you only have the current one in memory (rather than having many large blobs in memory). Sqlite deals with blobs a single objects, and doesn't let you read or write the value in small chunks as you seem to be looking for. You can't store and retrieve blobs that are bigger than your available memory. For large blobs, the consensus seems to be that you are best off storing the data in a file and storing the filename in your database. However you do lose the nice "one file per database" characteristic of sqlite by doing this. HTH Dennis Cote Thanks Dennis, We are currently storing very large data in a seperate file and store the filename in the database. The type of strings/blob that we are storing the DB can sometimes get big, but not so big that we require those to be in a file. The reason I would like to get the size of the data before they are in memory is to decide if I want to store that string/blob in memory or redirect them to a temporary file for the user to view the data. Shawn
Re: [sqlite] How to get the size of the value
Shawn Walker wrote: How do I determine the size of the value of the string/blob that is in the database? I would like to know how big the data so that I can determine how to handle the data if it's a large data so that I can put the data in a file instead of in memory. Shawn, You can use the sqlite3_column_bytes() API function to get the size of a string or blob, but by the time you can do this (i.e. after calling sqlite3_step()) it is already in memory and ready to be returned to you using sqlite3_column_blob() or sqlite3_column_text(). These functions return pointers to the buffer that holds the blob or string. You could perhaps use this to copy each individual blob to a file so you only have the current one in memory (rather than having many large blobs in memory). Sqlite deals with blobs a single objects, and doesn't let you read or write the value in small chunks as you seem to be looking for. You can't store and retrieve blobs that are bigger than your available memory. For large blobs, the consensus seems to be that you are best off storing the data in a file and storing the filename in your database. However you do lose the nice "one file per database" characteristic of sqlite by doing this. HTH Dennis Cote
Re: [sqlite] timeout question
On Thu, 28 Jul 2005, Ray Mosley wrote: >I am accessing a SQLite 2.8 database from an application running several >Windows systems systems using a NFS shared file. I am using the Tcl bindings >- TclPro 1.4.1. > The default timeout is set to 0; if I want to delay up to two seconds if >the DB is locked, does each application need to set the timeout value, or >only one? The timeout is an application property, rather than a database property, so each application that wants a timeout must set a timeout. Christian -- /"\ \ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \
[sqlite] How to get the size of the value
How do I determine the size of the value of the string/blob that is in the database? I would like to know how big the data so that I can determine how to handle the data if it's a large data so that I can put the data in a file instead of in memory. Thanks, Shawn
[sqlite] How do I backup sqlite data file
Hi, What is the most reasonable way to backup sqlite data file? When applications using that db file are stopped, simple file copy `cp active.db backup.db' works fine. But with long running applications, is it correct to assume asynchronous copy may result in inconsitent state of the db file, and if so, how do I backup it? Thanks in advance. -- Namekata Koji
[sqlite] timeout question
I am accessing a SQLite 2.8 database from an application running several Windows systems systems using a NFS shared file. I am using the Tcl bindings - TclPro 1.4.1. The default timeout is set to 0; if I want to delay up to two seconds if the DB is locked, does each application need to set the timeout value, or only one? Thanks. -- Ray Mosley
RE: AW: [sqlite] VB6 question
Attached (now in the WIKI) is a VB6 wrapper that is a bit different to most in that it binds to the sqlite DLL at runtime. Consequently, all you need to do is put this in your path along with the sqlite3.dll (or sqlite.dll if you want to use 2.8.x) and it sorts out the calls at runtime. The DLL also contains a Java JNI implementation that does the same thing. As with the VB6, you can call it from Java without having to worry about re-creating the DLL for each new release of sqlite. The zip contains VB6 and Java examples. As with sqlite, it's free and if you want the source code for the DLL I'll send it anyone that's interested. Steve -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] rg]On Behalf Of Gregory Letellier Sent: 28 July 2005 13:02 To: sqlite-users@sqlite.org Subject: Re: AW: [sqlite] VB6 question all the wrapper ar for 2.8 and i wan't use the 3.0 anyone known 3.0 wrapper ? Steve O'Hara a écrit : >Don't want to dampen your enthusiasm for this route but. why do you >think there are so many VB wrappers for SQLite? > >It's because you can't use the SQLite DLL directly from VB - some functions >will work but the essential ones won't. It's because the DLL returns things >like pointers to arrays of pointers which is not very groovy in VB (in fact, >you would have to resort to some OS calls to unravel that). > >Use one of the wrappers. > >Steve > > > > > > >-Original Message- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] >rg]On Behalf Of Gregory Letellier >Sent: 27 July 2005 11:17 >To: sqlite-users@sqlite.org >Subject: Re: AW: [sqlite] VB6 question > > >Ok Thank's for your help i will trying this !!! > >[EMAIL PROTECTED] a écrit : > > > >>Hi, >> >>unfortunately this has to do with the C calling convention used by >> >> >sqlite3.dll. By default DLLs compiled with C have the cdecl calling >convention, but VB only supports the stdcall calling convention. > > >>You must recompile sqlite using MS Visual C++ or other compiler and switch >> >> >the default calling convention from cdecl to stdcall in the compiler/linker >settings. > > >>HTH >>Michael >> >> >> >> >> >>>hello i'm trying to open a database with VB6 without wrapper >>> >>>i'm using sqlite3.dll >>> >>>and it's my code : >>> >>>Option Explicit >>>Private Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal filename >>>As String, ByRef dbHandle As Long) As Long >>>Private Declare Function sqlite3_open16 Lib "sqlite3.dll" (ByVal >>>filename As String, ByRef dbHandle As Long) As Long >>>Private Declare Sub sqlite3_close Lib "sqlite3.dll" (ByVal DB_Handle As >>>Long) >>> >>>Private Sub Form_Load() >>> Dim lRet As Long >>> Dim lDbHandle As Long >>> Dim sFilename As String >>> >>> sFilename = "c:\toto.db" >>> sqlite3_open sFilename, lDbHandle >>> MsgBox ("lRet=" & lRet) >>> MsgBox ("ldbhandle=" & lDbHandle) >>> sqlite3_close (lDbHandle) >>>End Sub >>> >>>when i launch it, i've an error 49 : Bad DLL calling convention >>> >>>anyone can help me ? where is my fault ? >>> >>>thx >>>Gregory Letellier >>> >>> >>> >>> >>> >>> >> >> >> >> > > > > > > >
Re: [sqlite] problem of creation of a data base
Thank you for your assistance, all functions very well thanks to you! I had to add: extern "C" { #include "os.h" } Excuse me if I have a little difficulties of understanding, I am newbie with Sqlite. Yours sincerely, Denis Lurkin.
Re: [sqlite] Commit and Rollback
On Jul 28, 2005, at 4:29 AM, Edwin Knoppert wrote: And i wish for a test if the transaction is already set or not, without using a callback. You already can: " int sqlite3_get_autocommit(sqlite3*); Test to see whether or not the database connection is in autocommit mode. Return TRUE if it is and FALSE if not. Autocommit mode is on by default. Autocommit is disabled by a BEGIN statement and reenabled by the next COMMIT or ROLLBACK. "
Re: [sqlite] problem of creation of a data base
> I tested with: > > extern "C" > { > #include > } > > but I always have the following error: > > ZeroLink: unknown symbol '__Z21sqlite3OsFullPathnamePKc' > > What to make? I have expected that the definition is in sqlite3.h, what is not the case. Try it with "os.h". Anway, I believe that already my first mail should have shown you the way to go. Gerald
Re: [sqlite] problem of creation of a data base
> I added: > > extern "C" > { > #include > } I wrote this in the moment when the loudspeakers at the walls told us all to leave the building, because of a technical problem. > and I have a problem of compilation: > > sqlite.h: No such file or directory > > > I tested with: > > extern "C" > { > #include > } So there is no need to complain because of an obvious mistake. Gerald
Re: [sqlite] problem of creation of a data base
I added: extern "C" { #include } and I have a problem of compilation: sqlite.h: No such file or directory I tested with: extern "C" { #include } but I always have the following error: ZeroLink: unknown symbol '__Z21sqlite3OsFullPathnamePKc' What to make? Thank you. Denis Lurkin.
Re: [sqlite] problem of creation of a data base
> Hello, > > I receive this error: > > ZeroLink: unknown symbol '__Z21sqlite3OsFullPathnamePKc' > > Why? name mangling, use: extern "C" { #include } Gerald
Re: [sqlite] Multi-threading.
Mrs. Brisby wrote: > My PII-350 easily handles 2 million local deliveries per hour, and it > fork()s for each one. > > As has been mentioned: If you think threads are going to make your > program fast, you don't know what you're doing. Like it or not, the world is bigger than just Unix. Some of us have to write code for other platforms, or even cross-platform. You can preach until you turn green about the dangers of threads in the hands of all the rest of us dumb idiots, but that doesn't change the fact that sometimes they are an appropriate (or the only) solution. Mrs. Brisby wrote: > Maybe people think that SQLite should serialize its own internals. Maybe > that's why people keep saying this. [snip] > meanwhile, two threads attempting to multiplex access to a single sqlite > handle are a) bound to be confused, and b) need those resource locks anyway. I don't think anyone is asking for SQLite to be serialized, or for it to work properly when a db handle is reused by multiple threads. Yes, there are a lot of questions about threads on the mailing list. Maybe it is because Kervin Pierre is right-- the documentation RE threads is poor. It's no big secret that Dr. Hipp is in the "threads are bad" camp, and so getting helpful information means spending hours reading through old mailing list posts, sorting through the chaff, trying to figure out what behavior applies to the current software version. (a number of significant threading issues have been resolved since 3.0 was released). There is a short article in the wiki on threads, but you have to know to look for it. Consider the lone FAQ entry on threading. It contains two helpful bits of advice. 1) Don't reuse db handles between threads. 2) Don't reuse db handles after fork(). Now imagine if that information was actually in a useful place, namely in the sqlite3_open API reference. Perhaps that would cut down on some new user confusion? -Eli
Re: [sqlite] Multi-threading.
Mrs. Brisby wrote: meanwhile, two threads attempting to multiplex access to a single sqlite handle are a) bound to be confused, and b) need those resource locks anyway. (background: I've been using threads on win32 since 1998. Sometimes to spread load across multiple CPUs, but usually just because I find it simpler than state logic to do everything in one thread. I'm not entering into this debate on threads vs. non-threads.) I just want to know why anyone would code using multiple threads accessing the same SQLITE connection object ( or handle or whatever you want to call it). I allocate a separate connection object for each thread and have ZERO troubles with locking so long as I use transactions properly. Assuming a multi-threaded (with in the same process) environment, what benefits are there to use a single (global?) SQLITE object (protected by a mutex, semaphore, critical section, whatever)? It seems so much more complicated and brittle.
[sqlite] problem of creation of a data base
Hello, I created a new project to which I included all the source files SQLITE 3.2.2 I have make a class DATABASE in which I created a method to create the base of data. int SqliteDatabase::create(const char *DbName) { int readOnly = 0; int rc = 0; char *zFullPathname = 0; OsFile fd; memset(&fd, 0, sizeof(fd)); if( sqlite3_malloc_failed ) { return SQLITE_NOMEM; } zFullPathname = sqlite3OsFullPathname(DbName); if( zFullPathname ) { rc = sqlite3OsOpenReadWrite(zFullPathname, &fd, &readOnly); } return rc; } When I make an object DATABASE, Database dbTemp; Then I make the create, dbTemp.create("tempoDB"); I receive this error: ZeroLink: unknown symbol '__Z21sqlite3OsFullPathnamePKc' Why? the method must be known because all the source files are included in the project... Thank you in advance, Denis Lurkin.
RE: [sqlite] UPDATE - crash when many columns
On Thu, 28 Jul 2005, Mark Allan wrote: > > >Thanks for the replies. > >My first assumption was that it was a memory issue. It seems that this is >only a problem with an UPDATE command, we do not have the same problem >when using the INSERT command with the same number of columns. Will the >UPDATE command require more memory to execute? If all you're doing is sqlite3_prepare, you haven't even reached the execution stage yet. I presume the issue is that UPDATE takes more parsing than INSERT, or at least creates a bigger memory footprint in the target VM. Do you have a stack trace at least? > >My embedded platform is as follows:- > >Processor: Sharp ARM7 LH79520 >Memory: 2Mb - SRAM cypress > >Our stack size is:- 0x7800 bytes (approx 30k) >Our heap size is:- 0x1C6000 bytes (approx 1.7Mb) Does the platform return NULL for out of memory errors? If OOM is caught by the platform, then it's more likely your stack that is running out. You should be able to verify based on your SP value, but 30K seems very small. > >The code is compiled using the IAR EWARM complier. > >Thanks again. > > > >> -Original Message- >> From: Christian Smith [mailto:[EMAIL PROTECTED] >> Sent: 27 July 2005 17:35 >> To: sqlite-users@sqlite.org >> Subject: Re: [sqlite] UPDATE - crash when many columns >> >> >> On Wed, 27 Jul 2005, Mark Allan wrote: >> >> > >> >Hi, >> > >> >I am using the SQL command:- >> > >> >UPDATE PATIENTS SET >> FIRSTNAME=?,SURNAME=?,SEX=?,WEIGHT=?,HEIGHT=?,FACTOR=?,DYSPNOE >> A_SCORE=?,SMOKING_STATUS=?,OCCUPATION=?,REFERRED_BY=? WHERE >> PATIENT_ID = '296' >> > >> >or similar, where the values for the ?'s are all binded via the >> >appropriate sqlite3_bind_* C functions. >> > >> >Now this will run fine when SQLite and our application is >> compiled and >> >run on Windows, but when the same code is run on our target >> harware it >> >will crash immediately at sqlite3_prepare(). >> > >> >If I update a smaller number of columns (maximum seems to be >> 6) then it >> >runs without any problems, but increase this and it will crash. >> >> >> How big is your stack and heap? You may be running out of memory when >> parsing the SQL statement. It may help if you stated what >> your embedded >> platform is. >> >> >> > >> >I cannot determine why this happens. Has anybody had the same or a >> >similar problem? Can anyone help me or help me confirm what >> the actual >> >problem may be? >> > >> >Thanks in advance for any help >> > >> >Mark >> > >> >> -- >> /"\ >> \ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL >> X - AGAINST MS ATTACHMENTS >> / \ >> > -- /"\ \ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \
Re: AW: [sqlite] VB6 question
all the wrapper ar for 2.8 and i wan't use the 3.0 anyone known 3.0 wrapper ? Steve O'Hara a écrit : Don't want to dampen your enthusiasm for this route but. why do you think there are so many VB wrappers for SQLite? It's because you can't use the SQLite DLL directly from VB - some functions will work but the essential ones won't. It's because the DLL returns things like pointers to arrays of pointers which is not very groovy in VB (in fact, you would have to resort to some OS calls to unravel that). Use one of the wrappers. Steve -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] rg]On Behalf Of Gregory Letellier Sent: 27 July 2005 11:17 To: sqlite-users@sqlite.org Subject: Re: AW: [sqlite] VB6 question Ok Thank's for your help i will trying this !!! [EMAIL PROTECTED] a écrit : Hi, unfortunately this has to do with the C calling convention used by sqlite3.dll. By default DLLs compiled with C have the cdecl calling convention, but VB only supports the stdcall calling convention. You must recompile sqlite using MS Visual C++ or other compiler and switch the default calling convention from cdecl to stdcall in the compiler/linker settings. HTH Michael hello i'm trying to open a database with VB6 without wrapper i'm using sqlite3.dll and it's my code : Option Explicit Private Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal filename As String, ByRef dbHandle As Long) As Long Private Declare Function sqlite3_open16 Lib "sqlite3.dll" (ByVal filename As String, ByRef dbHandle As Long) As Long Private Declare Sub sqlite3_close Lib "sqlite3.dll" (ByVal DB_Handle As Long) Private Sub Form_Load() Dim lRet As Long Dim lDbHandle As Long Dim sFilename As String sFilename = "c:\toto.db" sqlite3_open sFilename, lDbHandle MsgBox ("lRet=" & lRet) MsgBox ("ldbhandle=" & lDbHandle) sqlite3_close (lDbHandle) End Sub when i launch it, i've an error 49 : Bad DLL calling convention anyone can help me ? where is my fault ? thx Gregory Letellier
RE: AW: [sqlite] VB6 question
Don't want to dampen your enthusiasm for this route but. why do you think there are so many VB wrappers for SQLite? It's because you can't use the SQLite DLL directly from VB - some functions will work but the essential ones won't. It's because the DLL returns things like pointers to arrays of pointers which is not very groovy in VB (in fact, you would have to resort to some OS calls to unravel that). Use one of the wrappers. Steve -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] rg]On Behalf Of Gregory Letellier Sent: 27 July 2005 11:17 To: sqlite-users@sqlite.org Subject: Re: AW: [sqlite] VB6 question Ok Thank's for your help i will trying this !!! [EMAIL PROTECTED] a écrit : >Hi, > >unfortunately this has to do with the C calling convention used by sqlite3.dll. By default DLLs compiled with C have the cdecl calling convention, but VB only supports the stdcall calling convention. > >You must recompile sqlite using MS Visual C++ or other compiler and switch the default calling convention from cdecl to stdcall in the compiler/linker settings. > >HTH >Michael > > > >>hello i'm trying to open a database with VB6 without wrapper >> >>i'm using sqlite3.dll >> >>and it's my code : >> >>Option Explicit >>Private Declare Function sqlite3_open Lib "sqlite3.dll" (ByVal filename >>As String, ByRef dbHandle As Long) As Long >>Private Declare Function sqlite3_open16 Lib "sqlite3.dll" (ByVal >>filename As String, ByRef dbHandle As Long) As Long >>Private Declare Sub sqlite3_close Lib "sqlite3.dll" (ByVal DB_Handle As >>Long) >> >>Private Sub Form_Load() >> Dim lRet As Long >> Dim lDbHandle As Long >> Dim sFilename As String >> >> sFilename = "c:\toto.db" >> sqlite3_open sFilename, lDbHandle >> MsgBox ("lRet=" & lRet) >> MsgBox ("ldbhandle=" & lDbHandle) >> sqlite3_close (lDbHandle) >>End Sub >> >>when i launch it, i've an error 49 : Bad DLL calling convention >> >>anyone can help me ? where is my fault ? >> >>thx >>Gregory Letellier >> >> >> >> > > > >
Re: [sqlite] Sorry, trivail question probably, chr(0) in blob.
Sorry for asking, but is there a read blob for this without binding? At this moment i'm using ..GetTable() and seems to offer only null terminated strings. - Original Message - From: "Christian Smith" <[EMAIL PROTECTED]> To: Sent: Wednesday, July 27, 2005 6:13 PM Subject: Re: [sqlite] Sorry, trivail question probably, chr(0) in blob. On Wed, 27 Jul 2005, Edwin Knoppert wrote: I reread the faq hundred times but i don't understand the \000 remark. For INSERT how can i embed BLOB data having single quote and chr(0) bytes? Currently i replace all singlequotes with 2x single quotes and that works fine. The chr(0) byte did not succeed. I'm using the dll and don't do any c to prepare me the encoding call(s). Afaik this one should be obsolete with v3.x anyway is it? BLOBS can be inserted by using the form: X'x1x2x3..xn' Where: x1..xn are two hex-digit representation of data. eg. sqlite> select X'48656c6c6f20576f726c6400'; Hello World sqlite> select quote(X'48656c6c6f20576f726c6400'); X'48656C6C6F20576F726C6400' You'll have to convert to the hex form yourself, as SQL appears to have no way to quote NUL bytes within a string. Thanks! -- /"\ \ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \
Re: [sqlite] Sorry, trivail question probably, chr(0) in blob.
Wow, super! I made a very fast converter for that so.. Thanks! - Original Message - From: "Christian Smith" <[EMAIL PROTECTED]> To: Sent: Wednesday, July 27, 2005 6:13 PM Subject: Re: [sqlite] Sorry, trivail question probably, chr(0) in blob. On Wed, 27 Jul 2005, Edwin Knoppert wrote: I reread the faq hundred times but i don't understand the \000 remark. For INSERT how can i embed BLOB data having single quote and chr(0) bytes? Currently i replace all singlequotes with 2x single quotes and that works fine. The chr(0) byte did not succeed. I'm using the dll and don't do any c to prepare me the encoding call(s). Afaik this one should be obsolete with v3.x anyway is it? BLOBS can be inserted by using the form: X'x1x2x3..xn' Where: x1..xn are two hex-digit representation of data. eg. sqlite> select X'48656c6c6f20576f726c6400'; Hello World sqlite> select quote(X'48656c6c6f20576f726c6400'); X'48656C6C6F20576F726C6400' You'll have to convert to the hex form yourself, as SQL appears to have no way to quote NUL bytes within a string. Thanks! -- /"\ \ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \
Re: [sqlite] Commit and Rollback
And i wish for a test if the transaction is already set or not, without using a callback. Even better, nested tranactions would be the best. :) - Original Message - From: "Marco Bambini" <[EMAIL PROTECTED]> To: Sent: Thursday, July 28, 2005 9:24 AM Subject: [sqlite] Commit and Rollback I need to know when a commit or a rollback is executed, I know that I can use the sqlite_commit_hook routine to be notified of a commit command, but what about rollback? Is there a way to know (or to be notified) when a rollback happens? Thanks a lot for your help, Marco Bambini
Re: [sqlite] No Timeout during commit?
On Mon, 2005-07-25 at 12:34 -0700, R S wrote: > Hi, >I have 2 process accessing the DB, one reading and the other > writing. Often the process reading the DB could take long and could > block the other process from committing a bunch of records to the DB. > I noticed that when the reader process has the lock and the writer > process tries to commit a bunch of records in the DB, the writer > blocks forever till it obtains the lock? Is this intended? I could > also always try to commit a little later and the approach works well > for my particular app. Can the behavior be changed? > Thanks. > SQLite never blocks for any reason. If it cannot get a lock, it returns SQLITE_BUSY. Even if you call sqlite3_busy_timeout() it doesn't block - it polls. What OS are you using? What wrappers around SQLite are you using? What version of SQLite? -- D. Richard Hipp <[EMAIL PROTECTED]>
Re: [sqlite] UPDATE - crash when many columns
On Wed, 2005-07-27 at 16:52 +0100, Mark Allan wrote: > I seem to have a problem when I update more than 6 columns within a > single record at one time. All columns are in the same table, they are > either strings, integers or dates. > I just ran a test where create a table with 1 columns, insert several rows into that table, then change the value of all 1 columns all at once using a single UPDATE statement. The test script is over a half megabyte of SQL. It works fine on my desktop. This may be a problem with your embedded system - perhaps a stack overflow or something like that. -- D. Richard Hipp <[EMAIL PROTECTED]>
RE: [sqlite] UPDATE - crash when many columns
Thanks for the replies. My first assumption was that it was a memory issue. It seems that this is only a problem with an UPDATE command, we do not have the same problem when using the INSERT command with the same number of columns. Will the UPDATE command require more memory to execute? My embedded platform is as follows:- Processor: Sharp ARM7 LH79520 Memory: 2Mb - SRAM cypress Our stack size is:- 0x7800 bytes (approx 30k) Our heap size is:- 0x1C6000 bytes (approx 1.7Mb) The code is compiled using the IAR EWARM complier. Thanks again. > -Original Message- > From: Christian Smith [mailto:[EMAIL PROTECTED] > Sent: 27 July 2005 17:35 > To: sqlite-users@sqlite.org > Subject: Re: [sqlite] UPDATE - crash when many columns > > > On Wed, 27 Jul 2005, Mark Allan wrote: > > > > >Hi, > > > >I am using the SQL command:- > > > >UPDATE PATIENTS SET > FIRSTNAME=?,SURNAME=?,SEX=?,WEIGHT=?,HEIGHT=?,FACTOR=?,DYSPNOE > A_SCORE=?,SMOKING_STATUS=?,OCCUPATION=?,REFERRED_BY=? WHERE > PATIENT_ID = '296' > > > >or similar, where the values for the ?'s are all binded via the > >appropriate sqlite3_bind_* C functions. > > > >Now this will run fine when SQLite and our application is > compiled and > >run on Windows, but when the same code is run on our target > harware it > >will crash immediately at sqlite3_prepare(). > > > >If I update a smaller number of columns (maximum seems to be > 6) then it > >runs without any problems, but increase this and it will crash. > > > How big is your stack and heap? You may be running out of memory when > parsing the SQL statement. It may help if you stated what > your embedded > platform is. > > > > > >I cannot determine why this happens. Has anybody had the same or a > >similar problem? Can anyone help me or help me confirm what > the actual > >problem may be? > > > >Thanks in advance for any help > > > >Mark > > > > -- > /"\ > \ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL > X - AGAINST MS ATTACHMENTS > / \ >
Re: [sqlite] round ?
Oops, i didn't check cvstrack Many thanks ! Nicolas D. Richard Hipp wrote: On Thu, 2005-07-28 at 08:37 +0200, Nicolas Martin wrote: Some strange effect of the round expression : sqlite> select round(1-0.5); 0 sqlite> select round(2-0.5); 2 See http://www.sqlite.org/cvstrac/tktview?tn=1316. The problem results from inconsistent behavior in platform printf() functions. The fix was for SQLite to always use it's own internal printf() function.
Re: [sqlite] round ?
On Thu, 2005-07-28 at 08:37 +0200, Nicolas Martin wrote: > Some strange effect of the round expression : > > sqlite> select round(1-0.5); > 0 > sqlite> select round(2-0.5); > 2 See http://www.sqlite.org/cvstrac/tktview?tn=1316. The problem results from inconsistent behavior in platform printf() functions. The fix was for SQLite to always use it's own internal printf() function. -- D. Richard Hipp <[EMAIL PROTECTED]>
[sqlite] Accessing Database on Network
Hello, The documentation suggests that its unsafe to use SQLite when the database file is on a windows network server and various other machines may want to simultaneously access it. If however none of these machines change the data in the databse (all accesses are just queries) is it then completely safe? Presumably only querying the database (and not inserting/altering etc) translates internally in sqlite to opening the database in read_only mode, which is presumably safe to do in several clients concurrently? If so from what version of windows/sqlite can I be confident? -- Best regards, djm mailto:[EMAIL PROTECTED]
Re: [sqlite] round ?
My version in sqlite3 v3.22 on freebsd5.4 I will check on Windows on the same computer. Damian Slee wrote: I tried it on windows for you. sqlite3.exe v3.21 sqlite> select round(1-0.5); 1 sqlite> select round(2-0.5); 2 sqlite> select round(3-0.5); 3 sqlite> select round(4-0.5); 4 sqlite> select round(5-0.5); 5 sqlite> select round(6-0.5); 6 Maybe the math libarary on the C compiler you are using? -Original Message- From: Nicolas Martin [mailto:[EMAIL PROTECTED] Sent: Thursday, July 28, 2005 2:37 PM To: sqlite-users@sqlite.org Subject: [sqlite] round ? Some strange effect of the round expression : sqlite> select round(1-0.5); 0 sqlite> select round(2-0.5); 2 sqlite> select round(3-0.5); 2 sqlite> select round(4-0.5); 4 sqlite> select round(5-0.5); 4 sqlite> select round(6-0.5); 6 sqlite>
[sqlite] Commit and Rollback
I need to know when a commit or a rollback is executed, I know that I can use the sqlite_commit_hook routine to be notified of a commit command, but what about rollback? Is there a way to know (or to be notified) when a rollback happens? Thanks a lot for your help, Marco Bambini
RE: [sqlite] round ?
I tried it on windows for you. sqlite3.exe v3.21 sqlite> select round(1-0.5); 1 sqlite> select round(2-0.5); 2 sqlite> select round(3-0.5); 3 sqlite> select round(4-0.5); 4 sqlite> select round(5-0.5); 5 sqlite> select round(6-0.5); 6 Maybe the math libarary on the C compiler you are using? -Original Message- From: Nicolas Martin [mailto:[EMAIL PROTECTED] Sent: Thursday, July 28, 2005 2:37 PM To: sqlite-users@sqlite.org Subject: [sqlite] round ? Some strange effect of the round expression : sqlite> select round(1-0.5); 0 sqlite> select round(2-0.5); 2 sqlite> select round(3-0.5); 2 sqlite> select round(4-0.5); 4 sqlite> select round(5-0.5); 4 sqlite> select round(6-0.5); 6 sqlite> -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.6/59 - Release Date: 27/07/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.6/59 - Release Date: 27/07/2005