Re: [sqlite] [C++] Import sqlite3.dll and/or sqlite database as resource in project?

2008-08-24 Thread CAVALO SCHMIDT
salutations,

I don't understand exactly what you
mean by "library project". is it a
"Win32 Static Library"?
do I create the library project and
include "sqlite3.c" in it?
in this way, will sqlite be integrated
in the application, instead of located
in an external DLL file?
note: I'm using Visual C++ 6.0.

thank you in advance.

2008/8/24 Teg <[EMAIL PROTECTED]>:
> Hello CAVALO,
>
> Sunday, August 24, 2008, 12:12:05 PM, you wrote:
>
> CS> salutations,
>
> CS> so, I should just import the sqlite3.c file into
> CS> the project, not linking to sqlite3.lib?
> CS> is it necessary to #include this file in main.cpp,
> CS> or do we only need to import it in the project?
> CS> what about sqlite3.h?
> CS> is just "sqlite3.c" necessary for this?
>
> CS> thank you in advance.
>
>
> I created a library project, then in the dependencies, told the
> environment that my program depended on this library and when I build, it
> automatically includes this library into my program.
>
> Project/Project Dependencies is the menu.
>
> When I rebuild my app, SQLite gets built with it. When I debug, I can
> single step into SQLite if I need to.
>
> --
> Best regards,
>  Tegmailto:[EMAIL PROTECTED]
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [C++] Import sqlite3.dll and/or sqlite database as resource in project?

2008-08-24 Thread CAVALO SCHMIDT
salutations,

so, I should just import the sqlite3.c file into
the project, not linking to sqlite3.lib?
is it necessary to #include this file in main.cpp,
or do we only need to import it in the project?
what about sqlite3.h?
is just "sqlite3.c" necessary for this?

thank you in advance.

2008/8/10 D. Richard Hipp <[EMAIL PROTECTED]>:
>
> On Aug 10, 2008, at 2:12 PM, CAVALO SCHMIDT wrote:
>
>> salutations, using VC++ in WinXP.
>>
>> I would like to know if it's possible to import and use the
>> sqlite3.dll file and/or the sqlite database file as a resource in a
>> C++ project, so that it will be integrated to the final Win32
>> executable. how would it be possible to use sqlite3_open with a
>> database file stored as a resource in the application?
>
>
> If you want a stand-alone executable, do not use sqlite3.dll.
> Instead, use the source code file "sqlite3.c" and compile it into your
> application.
>
> If you have the content of an SQLite database file stored as a
> constant array of bytes in your program, you could have sqlite3 open
> this constant array as if it were a read-only database file by writing
> and registering your own custom VFS layer that reads from the constant
> byte array rather than a file.  You do not have to modify any of the
> core SQLite code to do this, but you do need to write your own VFS
> module, which will require that you have a deep understanding of how
> the SQLite core operates.
>
>
> D. Richard Hipp
> [EMAIL PROTECTED]
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [C++] Import sqlite3.dll and/or sqlite database asresource in project?

2008-08-10 Thread CAVALO SCHMIDT
thank you for your quick response.
do you mean extracting the file
temporarily (both the database
and the DLL) to the program's
folder?
but how would I do this (if this
question is relevant to this list)?
thank you in advance.

2008/8/10, Igor Tandetnik <[EMAIL PROTECTED]>:
> "CAVALO SCHMIDT" <[EMAIL PROTECTED]>
>  wrote in message
>  news:[EMAIL PROTECTED]
>
> > salutations, using VC++ in WinXP.
>  >
>  > I would like to know if it's possible to import and use the
>  > sqlite3.dll file and/or the sqlite database file as a resource in a
>  > C++ project, so that it will be integrated to the final Win32
>  > executable. how would it be possible to use sqlite3_open with a
>  > database file stored as a resource in the application?
>
>
> You would have to extract both from resources to a file on disk at
>  runtime, before you can use them.
>
>  Igor Tandetnik
>
>
>
>  ___
>  sqlite-users mailing list
>  sqlite-users@sqlite.org
>  http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] [C++] Import sqlite3.dll and/or sqlite database as resource in project?

2008-08-10 Thread CAVALO SCHMIDT
salutations, using VC++ in WinXP.

I would like to know if it's possible to import and use the
sqlite3.dll file and/or the sqlite database file as a resource in a
C++ project, so that it will be integrated to the final Win32
executable. how would it be possible to use sqlite3_open with a
database file stored as a resource in the application?

thank you.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqite wildcard search with indexing

2008-07-26 Thread CAVALO SCHMIDT
CAVALO SCHMIDT <[EMAIL PROTECTED]> writes:

> 
> Salutations,
> 
> Is it possible to do a simple wildcard/regexp-type search in sqlite
> databases, but with indexing? For example, if I want to search for the
> string "aCa", we would do only one SELECT * FROM a WHERE a = "aCa",
> and it would interpret "C" as any letter in "bdgjklmnpqrstv". So, one
> SELECT would be equivalent to several ones with "C" replaced by any of
> those letters:
> SELECT * FROM a WHERE a = "aba"
> SELECT * FROM a WHERE a = "ada"
> SELECT * FROM a WHERE a = "aga"
> SELECT * FROM a WHERE a = "aja"
> ...
> Or, for example, if I want to call SELECT * FROM a WHERE a = "string",
> have it search for "string", " string", "string " and " string ".
> I think that, in an indexed database, making several SELECT's like
> that would be faster than using LIKE or REGEXP.
> Of course, we could implement the generation of all the SELECT's in C
> and/or Perl, for example, but it would be extremely more practical if
> we could call SELECT only once and have it consider "C" as any
> consonant, and it would be equivalent to calling SELECT several times.
> 
> Thank you in advance.


I would appreciate if anyone could give a solution to
this problem. How to write a SELECT query that considers
the letter "C" as any letter in "bdgjklmnpqrstv"? Or that
considers that there may be spaces before and after the word
searched?
Thank you in advance.

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] sqite wildcard search with indexing

2008-07-21 Thread CAVALO SCHMIDT
Salutations,

Is it possible to do a simple wildcard/regexp-type search in sqlite
databases, but with indexing? For example, if I want to search for the
string "aCa", we would do only one SELECT * FROM a WHERE a = "aCa",
and it would interpret "C" as any letter in "bdgjklmnpqrstv". So, one
SELECT would be equivalent to several ones with "C" replaced by any of
those letters:
SELECT * FROM a WHERE a = "aba"
SELECT * FROM a WHERE a = "ada"
SELECT * FROM a WHERE a = "aga"
SELECT * FROM a WHERE a = "aja"
...
Or, for example, if I want to call SELECT * FROM a WHERE a = "string",
have it search for "string", " string", "string " and " string ".
I think that, in an indexed database, making several SELECT's like
that would be faster than using LIKE or REGEXP.
Of course, we could implement the generation of all the SELECT's in C
and/or Perl, for example, but it would be extremely more practical if
we could call SELECT only once and have it consider "C" as any
consonant, and it would be equivalent to calling SELECT several times.

Thank you in advance.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_prepare / sqlite3_step not working

2007-12-13 Thread CAVALO SCHMIDT
Thank you, it now works.

2007/12/13, Dennis Cote <[EMAIL PROTECTED]>:
>
> CAVALO SCHMIDT wrote:
> > In the following simple C code (in Console program):
> >
> > sqlite3 *db;
> > int ret = sqlite3_open("dict.db", );
> > sqlite3_stmt *stmt;
> > char sql[256];
> > sprintf(sql, "%s", "select * from a where a = 'key1'");
> > int rc = sqlite3_prepare(db, sql, 0, , 0);
> > while(sqlite3_step(stmt) == SQLITE_ROW) {
> >printf( (char *)sqlite3_column_text(stmt, 1) );
> >   };
> > sqlite3_finalize(stmt);
> > sqlite3_close(db);
> >
> > I must have made a very simple beginner mistake, because an error
> happens.
> > sqlite3_prepare returns SQLITE_OK, but sqlite3_step returns 21
> > = SQLITE_MISUSE.
> > Can anyone tell me what I did wrong? It happens with any database I test
> it
> > with. Just for information, sqlite3_exec works perfectly.
> >
> >
> >
>
> You have called sqlite3_prepare incorrectly. The third argument is the
> length of the sql string if it is positive. To have sqlite scan until
> the end of the string you need to pass a negative number. Tyr this
> instead.
>
>int rc = sqlite3_prepare(db, sql, -1, , 0);
>
> HTH
> Dennis Cote
>
>
>
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


[sqlite] sqlite3_prepare / sqlite3_step not working

2007-12-13 Thread CAVALO SCHMIDT
Salutations,

In the following simple C code (in Console program):

sqlite3 *db;
int ret = sqlite3_open("dict.db", );
sqlite3_stmt *stmt;
char sql[256];
sprintf(sql, "%s", "select * from a where a = 'key1'");
int rc = sqlite3_prepare(db, sql, 0, , 0);
while(sqlite3_step(stmt) == SQLITE_ROW) {
   printf( (char *)sqlite3_column_text(stmt, 1) );
  };
sqlite3_finalize(stmt);
sqlite3_close(db);

I must have made a very simple beginner mistake, because an error happens.
sqlite3_prepare returns SQLITE_OK, but sqlite3_step returns 21
= SQLITE_MISUSE.
Can anyone tell me what I did wrong? It happens with any database I test it
with. Just for information, sqlite3_exec works perfectly.

Thank you in advance.


Re: [sqlite] SQLite gives Access Violation in Windows

2007-12-12 Thread CAVALO SCHMIDT
Thank you, it worked.

2007/12/12, Uwe Sander <[EMAIL PROTECTED]>:
>
> Hi,
> Am Mittwoch, 12. Dezember 2007 schrieb CAVALO SCHMIDT:
> > Ok, I'm sending to you a zip file with the Pelles C project, together
> > with the database (a small test database, with a key1 with 2 values
> > [which doesn't throw errors] and a key2 with six values [which throws
> the
> > error]); note that, in my installation, I put sqlite3.lib and sqlite3.h,
> > respectively, in the Lib and in the Include folders inside Pelles C
> > installation folder; I included the LIB I created from the DEF in the
> zip
> > file, but it wasn't possible, due to size limitations, to include
> neither
> > the DLL nor the H.
>
> you have to tell the compiler that the calling convention for the callback
> is the same as sqlite expect it to be. The default for windows
> applications
> is stdcall, but I think it should be cdecl for the lib you use.
>
> HIH
> Uwe
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


Re: [sqlite] SQLite gives Access Violation in Windows

2007-12-12 Thread CAVALO SCHMIDT
Thank you for the response. So, how can I fix it? Can it have anything to do
with sqlite3.lib?
Is it a bug? Thank you in advance.


2007/12/12, Trevor Talbot <[EMAIL PROTECTED]>:
>
> On 12/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > "Trevor Talbot" <[EMAIL PROTECTED]> wrote:
>
> > > > test.exe: WinMain( ) + 71
> > > > sqlite3.dll: sqlite3_exec( ) + 154
> > > > sqlite3.dll: sqlite3_column_text( ) + 1A
> > > > sqlite3.dll: sqlite3_data_count( ) + AC
> > > > ntdll.dll: RtlEnterCriticalSection( ) + B
>
> > > Hmm, looks like a fault within SQLite's internal mutex handling. What
> > > version of sqlite is this, and did you compile it yourself? I'm
> > > wondering if it's not a compiler-related bug.
>
> > sqlite3_data_count() never touches a mutex.  sqlite3_data_count()
> > consists of 3 lines of code that extracts a value from the structure
> > that is passed in as its only parameter.
> >
> > Furthermore, sqlite3_column_text() does not call sqlite3_data_count(),
> > either directly or through intermediate subroutines.
> >
> > So I would be very suspicious about drawing conclusions from the
> > stack trace above.
>
> Most of the Windows debugging tools will, in the absence of full
> symbols, choose the closest public/exported symbol and print an
> instruction offset from it. Not many optimizers are aggressive about
> reordering functions, so usually code gets laid out in the order it
> was written. That puts the mutex-related call not very far after
> sqlite3_data_count(), like perhaps columnMem().
>
> Still quite a bit of guesswork involved, but that's pretty much the
> only way it's going to get from sqlite into RtlEnterCriticalSection(),
> and it'll do as a starting point.
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


Re: [sqlite] SQLite gives Access Violation in Windows

2007-12-12 Thread CAVALO SCHMIDT
It is SQLite 3.4.2, and I downloaded the ready binary, the DLL and sqlite3.h;
I didn't compile anything. But the sqlite3.lib didn't come ready; it came as
sqlite3.def together with the DLL, then I made it into a sqlite3.lib by
using the LIB.EXE utility of Visual Studio 6.0 -> LIB.EXE /DEF:sqlite3.def.
Thank you in advance.


2007/12/12, Trevor Talbot <[EMAIL PROTECTED]>:
>
> On 12/12/07, CAVALO SCHMIDT <[EMAIL PROTECTED]> wrote:
>
> > For example, in a database where searching for text "key1" (column a)
> > returns "value1", "value2", "value3", and "value4" in column b, the
> callback
> > fnuction of that code would be called THREE times, returning thus three
> > message boxes:
> >  - key1 -> value1
> >  - key1 -> value2
> >  - key1 -> value3
> > And, in the fourth call to the callback function in this same
> sqlite3_exec
> > call, it gives "Access Violation", and never gets to reach the callback
> > function for the fourth time. But, if there were only value1, value2 and
> > value3, it would work fine. Actually, if we called, several times,
> > sqlite3_exec() for an SELECT that return 3 or less calls to the callback
> > function, it would work fine. Thus, it runs into trouble apparently when
> it
> > is about to call the callback function for the fourth time in a same
> > sqlite3_exec.
>
> > test.exe: WinMain( ) + 71
> > sqlite3.dll: sqlite3_exec( ) + 154
> > sqlite3.dll: sqlite3_column_text( ) + 1A
> > sqlite3.dll: sqlite3_data_count( ) + AC
> > ntdll.dll: RtlEnterCriticalSection( ) + B
>
> Hmm, looks like a fault within SQLite's internal mutex handling. What
> version of sqlite is this, and did you compile it yourself? I'm
> wondering if it's not a compiler-related bug.
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


Re: [sqlite] SQLite gives Access Violation in Windows

2007-12-12 Thread CAVALO SCHMIDT
Thank you for the answer. Actually, I've already scattered MessageBox()
calls through the code, and I've found out exactly where the error happens.
For example, in a database where searching for text "key1" (column a)
returns "value1", "value2", "value3", and "value4" in column b, the callback
fnuction of that code would be called THREE times, returning thus three
message boxes:
 - key1 -> value1
 - key1 -> value2
 - key1 -> value3
And, in the fourth call to the callback function in this same sqlite3_exec
call, it gives "Access Violation", and never gets to reach the callback
function for the fourth time. But, if there were only value1, value2 and
value3, it would work fine. Actually, if we called, several times,
sqlite3_exec() for an SELECT that return 3 or less calls to the callback
function, it would work fine. Thus, it runs into trouble apparently when it
is about to call the callback function for the fourth time in a same
sqlite3_exec.
Call stack just after the error happens (I'm not very sure of what it means,
because I'm a beginner):
KERNEL32.dll: GetCurrentDirectoryW( ) + 44
test.exe: 00401265
test.exe: WinMain( ) + 71
sqlite3.dll: sqlite3_exec( ) + 154
sqlite3.dll: sqlite3_column_text( ) + 1A
sqlite3.dll: sqlite3_data_count( ) + AC
ntdll.dll: RtlEnterCriticalSection( ) + B
I'm not very sure if it is all the information that you need.
Thank you in advance.
2007/12/12, Trevor Talbot <[EMAIL PROTECTED]>:

> On 12/12/07, CAVALO SCHMIDT <[EMAIL PROTECTED]> wrote:
>
> > I'm programing in C, new to SQLite, in Windows, with the Pelles C
> Compiler
> > for Windows.
>
> > It works well. BUT, when I try to put this code in a Win32 application,
> like
> > inside a WinMain procedure, for example, a strange behavior happens:
> > everytime sqlite3_exec finds exactly more than 3 records in the
> database, it
> > gives an "Access Violation" error. Pelles C's debugger gives "Exception:
> > Access Violation", apparently in NTDLL.DLL. It happens with any database
> of
> > any size, as long as SELECT returns more than 3 results. We tested it in
> 2
> > computers Windows XP Pro (one of them 2.4 GHz and 1GB RAM, and the
> > other 1.1GHz and 384 MB RAM), and, in both of them, the error happens
> > every time
> > SELECT finds more than 3 records (so, I could never have noticed it if I
> had
> > tested it only with SELECTs that return 3 or less results); we tried to
> > increase Stack Reserve size, but no difference. Important to notice is
> the
> > fact that it works fine in a Console application, and also in
> sqlite3.exe it
> > works fine.
>
> You'll need to get more information out of the debugger, like a stack
> trace. Alternatively, scatter MessageBox() calls through your code to
> find out where it is when it runs into trouble.
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


[sqlite] SQLite gives Access Violation in Windows

2007-12-12 Thread CAVALO SCHMIDT
Salutations,

I'm programing in C, new to SQLite, in Windows, with the Pelles C Compiler
for Windows.
When I create a Console project and put, for example, the following commands
(an SQLite connection with callback function):

static int callback(void *NotUsed, int argc, char **argv, char **azColName){
  // Show "column 1 -> column 2" in a MessageBox
  char output[256];
  sprintf(output, "%s -> %s", argv[0], argv[1]);
  MessageBox(0, output, "", 0);
  return 0;
}

sqlite3 *db;
sqlite3_open("dict.db", );
char *zErrMsg;
int rc;
rc = sqlite3_exec(db, "select * from a where a = 'key1'", callback, 0,
);
rc = sqlite3_exec(db, "select * from a where a = 'key2'", callback, 0,
);

It works well. BUT, when I try to put this code in a Win32 application, like
inside a WinMain procedure, for example, a strange behavior happens:
everytime sqlite3_exec finds exactly more than 3 records in the database, it
gives an "Access Violation" error. Pelles C's debugger gives "Exception:
Access Violation", apparently in NTDLL.DLL. It happens with any database of
any size, as long as SELECT returns more than 3 results. We tested it in 2
computers Windows XP Pro (one of them 2.4 GHz and 1GB RAM, and the
other 1.1GHz and 384 MB RAM), and, in both of them, the error happens
every time
SELECT finds more than 3 records (so, I could never have noticed it if I had
tested it only with SELECTs that return 3 or less results); we tried to
increase Stack Reserve size, but no difference. Important to notice is the
fact that it works fine in a Console application, and also in sqlite3.exe it
works fine.
Any ideas? Thank you in advance.