Re: [sqlite] sqlite3_open function

2007-08-10 Thread fred238

Eric Pankoke a e'crit :

The best way is to just check if the file exists in whatever language
you're using before you call sqlite3_open.

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
 
-Original Message-
From: fred238 [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 10, 2007 11:28 PM

To: sqlite-users@sqlite.org
Subject: [sqlite] sqlite3_open function

hello,

Is there a way to not create a database while the db file is not found
with the sqlite3_open function ?

Why don't just create a create_table function instead of ?

regards,

fred.



-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-





ok, i will do that.

thank you.


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] sqlite3_open function

2007-08-10 Thread Eric Pankoke
The best way is to just check if the file exists in whatever language
you're using before you call sqlite3_open.

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
 
-Original Message-
From: fred238 [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 10, 2007 11:28 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] sqlite3_open function

hello,

Is there a way to not create a database while the db file is not found
with the sqlite3_open function ?

Why don't just create a create_table function instead of ?

regards,

fred.



-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] sqlite3_open function

2007-08-10 Thread fred238

hello,

Is there a way to not create a database while the db file is not found with the 
sqlite3_open function ?

Why don't just create a create_table function instead of ?

regards,

fred.


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] ~/sqliterc example/documentation avaible?

2007-08-10 Thread Trevor Talbot
On 8/10/07, Brickl Roland <[EMAIL PROTECTED]> wrote:

> where can i find information about how the config-file should look like and 
> what is possible?

There is no ~/sqliterc or config file.  SQLite is an embedded database
engine; applications use it in application-specific ways.

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Problem loading extension in Delphi (FTS2)

2007-08-10 Thread Henrik Ræder
   Hi Ralf

   Thanks for the tip.

   I checked it out, and it's a bit complex, but looks very clean. I'll
probably update to that component set at a later date.

   -Henrik

2007/8/10, Ralf Junker <[EMAIL PROTECTED]>:
>
> Hello Henrik Ræder,
>
> >I'm trying to load the FTS2 extension in Delphi, using the Aducom
> >components. Am really close, but still stuck, and thinking it's a problem
> >with the parameter to sqlite3_enable_load_extension().
>
> DISQLite3 (http://www.yunqa.de/delphi/sqlite3/) does not expose such
> problems.
>
> Look at the full text search demo project which incorporates both FTS1 and
> FTS2 into a single *.exe application, with _no_ DLLs or external files
> needed.
>
> The new customizable tokenizer interface will be demonstrated by a
> Unicode-aware Pascal tokenizer with the upcoming version of DISQLite3 as
> soon as the FTS vacuum fix is official released.
>
> Ralf
>
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


-- 
Henrik Ræder Clausen
CD-rom editor
Komputer for alle

Jidoka Development   Hougårdsvej 29   8220 Brabrand   DenmarkTlf +45
6186 0442


[sqlite] SQLITE_CORRUPT: database disk image is malformed

2007-08-10 Thread Andrew Finkenstadt
Is there a good way/tool to determine what went wrong in a database file
reporting SQLITE_CORRUPT?

The details I have so far are:  machine (running Windows XP) locked up hard
while executing our application.  Repeatable hard-lock at a certain point.
(Hard lock is defined as no mouse, no keyboard, no display update,
necessitating reset button or power cycle.)

I've noticed that disk drivers will lie about whether data has been truly
committed to physical media in the interests of passing a benchmark faster.
I suspect something is going on here.


[sqlite] Help with performance...

2007-08-10 Thread Ken

I'm looking for your help solving a performance issue:

Master db and an attached db. called A

Table x and table Y are identical in both the master and Attached database.
table Z is built to determine the set of rows to copy and has an index on the 
id field.

The goal is to move data from many attached db's to the master.

SQL statements:
Begin;
   insert into x 
select  x1.* from a.x x1 , Y
   where x1.id = y.id ;
commit;
takes 4.08 seconds to move 3904 rows.

begin;
   insert into y 
 select  y1.* from a.x y1 , Y
where y1.id = y.id ;
 commit;
  Takes 2.19 seconds to move 2676 rows.

So X is moved at 922 r/s  and y is moved at 1221 r/s.
Table X has  16 columns and no blobs
Table Y has 22 columns one of which is a blob.

All columns are integers except for the blob on table y.

So why is the X copy performance 25% slower than Y ?

Page size is 4k.
Cache size is 4000.
locking_mode = exclusive.
Synchronous off

Is there any way to disable journaling? 
I can always re-create the DB should anything fail. 

Any other ideas on how to make this run quicker?

Thanks,
Ken


 




Re: [sqlite] building 3.4.1

2007-08-10 Thread Victor Secarin
I have solved the failed tests reported a few days ago, and I have now 
the proof that none of them is blamed on sqlite.

For what it is worth, here are the details:

The source is sqlite 3.4.1 last updated on August 9

The platforms and compilers are:
- Enterprise 3, 32 and 64 bits, gcc 3.2.3
- Enterprise 4, 64 bits, gcc 3.4.4
- Fedora 5, 64 bits, gcc 4.1.1

The failures that recurred after several fulltest runs were:
- lock4-1.3 (error, the database is locked)  on Enterprise 3, 32 bits
- malloc2-1.1.34 and malloc2.1.5, on Enterprise 3, 32 bits (checksums)
- printf-8.1 and printf-8.2 on Enterprise 3 and 4, 64 bits (error, 
integer value too large to represent)


They were solved as follows:

1. lock4 seemed to be a delayed lock reset by the NFS service, affecting 
only slow client machines.
When I ran fulltest it happened;  meanwhile testfixture lock4.test, run 
after a couple of minutes delay, would succeed the first time; if run 
again immediately, it would fail again.

Solved by just moving everything to a local disk and repeating the tests.

2. malloc2.test would fail only if run immediately after malloc.test or 
during fulltest. Probably another instance of something being delayed. 
Stopped happening after the move to the local disk.


3. printf.test: The value too large to represent was 0x8000 and the 
message comes from tclObj.c:Tcl_Get_Int. Solved by getting tcl 8.4.15, 
where the test that deals with differences between the int type and long 
type on 64 bit boxes has been changed. On Fedora5 which has tcl8.4.13 
this does not happen either.


The only useful lesson seems to be (a) use a new tcl and (b) stay away 
from networks when testing or at least (c) test on a fast computer.


just my two bits,
yours truly,
Victor Secarin



Joe Wilson wrote:
The string "integer value too large to represent" is not found in 
sqlite sources, so I assume it is an error in either in Tcl or the tcl 
test harness.


I have no idea why the checksum of the databases in malloc2-1.1.28.5
is different, or whether it is harmless.

As for the malloc2.1.5 failure, as far as I can tell looking at the test, 
an empty abc table should be present.


I have no idea about lock4-1.3.

I'd suggest to make a ticket for each of these test errors.

  http://www.sqlite.org/cvstrac/tktnew

--- Victor Secarin <[EMAIL PROTECTED]> wrote:
  
Here are the fulltest errors I get trying to build sqlite 3.4.1 with the 
included gcc on Enterprise 3, 4 and Fedora 5.
After building tcl8.4.7 and installing it in /usr/local, I was able to 
configure with "--with-tcl=/usr/local/lib" and build the two libraries 
completely and then run the fulltest on Enterprise 3 as well.
I hope someone will find these useful and will be able to tell me to 
what extent the builds may be used or not.
Meanwhile, I will redo these builds, wit the Intel 9.1.052 compiler this 
time, and I will post the fulltest results.

Please advise, and thank you very much,
Victor Secarin


A. Fulltest on Fedora 5 (64 bits) with glibc-2.4-11/gcc-4.1.1:
===
3 errors out of 240587 tests
Failures on these tests: lock4-1.3 malloc2-1.1.28.5 malloc2.1.5

lock4-1.3...
Error: database is locked
malloc2-1.1.28.5...
Expected: [7150405b58e993f161c43b93edd13553]
 Got: [bc598bca7e7514b7f36e3e3d178a97ba]
malloc2.1.5...
Error: no such table: abc

B. Fulltest on RedHat Enterprise 4 update 5 (64 bits) with 
glibc-2.3.4-2.36/gcc-3.4.4:


2 errors out of 127702 tests
Failures on these tests: printf-8.1 printf-8.2

printf-8.1...
Error: integer value too large to represent
printf-8.2...
Error: integer value too large to represent


C. Fulltest on Enterprise 3  update 9 (64 bits) with 
glibc-2.3.2-95.50/gcc-3.2.3:

===
2 errors out of 127702 tests
Failures on these tests: printf-8.1 printf-8.2

printf-8.1...
Error: integer value too large to represent
printf-8.2...
Error: integer value too large to represent


D. Fulltest on Enterprise 3  update 9 (32 bits) with 
glibc-2.3.2-95.50/gcc-3.2.3:


3 errors out of 110199 tests
Failures on these tests: lock4-1.3 malloc2-1.1.34.5 malloc2.1.5

lock4-1.3...
Error: database is locked
malloc2-1.1.34.5...
Expected: [7150405b58e993f161c43b93edd13553]
 Got: [bc598bca7e7514b7f36e3e3d178a97ba]
malloc2.1.5...
Error: no such table: abc


please advise, and thank you very much,
Victor Secarin


Joe Wilson wrote:


Can you post the output for the failed tests?

i.e.:

 footest-13.1...
 Expected: [10]
  Got: [0]

--- Victor Secarin <[EMAIL PROTECTED]> wrote:
  
  
Hello, everyone. I just started to look at the software and I have two 
questions:



Question 1:

Building sqlite-3.4.1, as obtained from the cvs, on Fedora 5, 64 bits, 
with gcc 4.1.1, over glibc-2.4-11, and tcl/tcl-devel 

Re: [sqlite] ~/sqliterc example/documentation avaible?

2007-08-10 Thread drh
Brickl Roland <[EMAIL PROTECTED]> wrote:
> 
> "Feature Request": Column-definition INT should be parsed
> as INTEGER in sql-code.
> 

It is.  At least it is for the purpose of computing column
affinity.  For the INTEGER PRIMARY KEY you are required to
spell out "INTEGER".  We cannot change the latter without 
breaking backwards compatibility, which is something we are 
unwilling to do.

--
D. Richard Hipp <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] ~/sqliterc example/documentation avaible?

2007-08-10 Thread Brickl Roland
Hallo,

where can i find information about how the config-file should look like and 
what is possible?
And is there a site with informations about sqlite in other languages avaible?

"Feature Request": Column-definition INT should be parsed as INTEGER in 
sql-code.

Sincerely,
Brickl Roland


  Wissenswertes für Bastler und Hobby Handwerker. BE A BETTER HEIMWERKER! 
www.yahoo.de/clever

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Strings vs Integers

2007-08-10 Thread Dan Kennedy
On Fri, 2007-08-10 at 09:28 -0700, Scott Baker wrote:
> Internally does sqlite store the following SQL statements differently?
> 
> 
> INSERT INTO table (foo) VALUES (1024);
> 
> vs
> 
> INSERT INTO table (foo) VALUES ('1024');

Depends on the type specified for 'foo' in the CREATE
TABLE statement. The answer is yes if the affinity of
the column is NONE.

  http://www.sqlite.org/datatype3.html#affinity

Dan.



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Re: Strings vs Integers

2007-08-10 Thread Igor Tandetnik

Scott Baker  wrote:

Internally does sqlite store the following SQL statements differently?


INSERT INTO table (foo) VALUES (1024);

vs

INSERT INTO table (foo) VALUES ('1024');


SQLite doesn't store statements. I guess you are asking how the value is 
stored.


That depens on how the column was declared in CREATE TABLE statement. 
For more details, see


http://sqlite.org/datatype3.html

Igor Tandetnik 



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Strings vs Integers

2007-08-10 Thread Scott Baker
Internally does sqlite store the following SQL statements differently?


INSERT INTO table (foo) VALUES (1024);

vs

INSERT INTO table (foo) VALUES ('1024');

-- 
Scott Baker - Canby Telcom
RHCE - System Administrator - 503.266.8253

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Problem loading extension in Delphi (FTS2)

2007-08-10 Thread Ralf Junker
Hello Henrik Ræder,

>I'm trying to load the FTS2 extension in Delphi, using the Aducom
>components. Am really close, but still stuck, and thinking it's a problem
>with the parameter to sqlite3_enable_load_extension().

DISQLite3 (http://www.yunqa.de/delphi/sqlite3/) does not expose such problems. 

Look at the full text search demo project which incorporates both FTS1 and FTS2 
into a single *.exe application, with _no_ DLLs or external files needed.

The new customizable tokenizer interface will be demonstrated by a 
Unicode-aware Pascal tokenizer with the upcoming version of DISQLite3 as soon 
as the FTS vacuum fix is official released.

Ralf 


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Threading issues in SQLite

2007-08-10 Thread John Stanton
You might find that using one thread and accessing the four data sets 
sequentially yields you a better result.  You will use the one Sqlite 
cache and get some benefit from not creating and detroying multiple 
caches and connections.


Bharath Booshan L wrote:

Hello All,

 I am using SQLite in one my application and I require to retrieve around
4-5 sets of information simultaneously. I have opted to run the queries in
separate threads which seems obvious choice here.

 However, I came to know from one of the documents in sqlite.org that single
connection cannot be used simultaneously across threads.

 So I would like to hear any suggestions regarding the best wary to open &
manage multiple connections i.e.

a) Is it efficient to create new connections in separate thread each time
when the query needs to be executed? ( Here I am worried about the time
taken to open connection )

b) Is it efficient to create the number of connections required, in a single
thread and use it in different threads? ( although a connection will not be
used simultaneously and this will eliminate the effort to create different
connections but we need to ensure that a connection is used simultaneously
in different threads)

Looking forward to your suggestions,

Bharath Booshan L   




---
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an 
intended recipient, please notify the sender and delete all copies. Emails to 
and from our network may be logged and monitored. This email and its 
attachments are scanned for virus by our scanners and are believed to be safe. 
However, no warranty is given that this email is free of malicious content or 
virus.



-
To unsubscribe, send email to [EMAIL PROTECTED]
-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Object Oriented Question About Adding a vector inside the callback function

2007-08-10 Thread John Stanton
Sqlite has a feature where you can contanenate SQL statements and 
prepare and step them in a loop.  Prepare returns a pointer to the start 
of the next statement.


The basic prepare/step/reset activity requires that there be a loop to 
handle multiple rows, busy returns and possible errors.


Stephen Sutherland wrote:
okay i'm trying to use preparestatement and step and finalize. 
  I have some  quick questions about this legacy.c code. 
   
  First I notice that it has a while loop within a while loop. 
  Question: when I implement this prepared statement, will I also need a while loop within a while loop ? 
   
  Just double checking 
   
  I noticed rc = sqlite3_step(pStmt); is the start of the inner while loop. 
  I'm guessing the inner while loop is needed with pStmt contains multiple SQl statements right ? 
   
  Thanks 
  STev 
   
  


Dennis Cote <[EMAIL PROTECTED]> wrote:
  Stephen Sutherland wrote:

Hi 


I am using the 'quick start' C-styled code for sqlite3 
http://www.sqlite.org/quickstart.html
I think I'm running into a problem trying to put it in classes to make it somewhat object oriented. So I'm asking for help about how to make it object-oriented - or to confirm whether what I'm doing is object oriented. 
Here is the code: 


[code]
//callback function
static int callback(void *NotUsed, int argc, char **argv, char **azColName)
{
int i;
for(i=0; i> printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
};

// this callback is referenced here. 
void MyClass::executeSQLStatement()

{
rc = sqlite3_exec(db, "select * from table1" , callback, 0, );
};

[/code]


However I am trying to add a vector in the callback function to store the 
results. When I put the vector in it seems I am forced to do something like 
this:


[code]
vector vecX;

static int callback(void *NotUsed, int argc, char **argv, char **azColName)
{
int i;
for(i=0; i> printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
vecX.push_back(argv[3]);

printf("\n");
return 0;
};
[/code]
Now this doesn't seem object oriented ? 
Nor do I understand how I would access this vector from other classes ? 
And I don't know how this vector which I created can be considered part of the class ? it seems to me to only have page scope. 
Any advice on how to make my vector object oriented or accessible by other classes ? 

Thanks in Advance 
Stephen 



-
Pinpoint customers who are looking for what you sell. 




Stephen,

You should look into using the newer prepare/step API functions instead 
of the callback mechanism. It will make your code clearer, and will 
probably execute faster as well.


The new API is used to implement the current version of sqlite3_exec 
that uses the callback mechanism so you can look at that code to see 
how the new API is used. The following excerpt is from the file legacy.c 
in the sqlite source. It shows how sqlite uses the new API functions to 
build the arrays of strings it passes to the callback function.


By using the new API functions directly you can avoid the overhead of 
converting all the database fields into string and building these 
arrays, only to have your callback function iterate over the string 
arrays and convert the values back into other types (for non string 
fields anyway) and then stuff them into vectors. You can extract the 
fields and store them directly into the vectors you want.


/*
** Execute SQL code. Return one of the SQLITE_ success/failure
** codes. Also write an error message into memory obtained from
** malloc() and make *pzErrMsg point to that message.
**
** If the SQL is a query, then for each row in the query result
** the xCallback() function is called. pArg becomes the first
** argument to xCallback(). If xCallback=NULL then no callback
** is invoked, even for queries.
*/
int sqlite3_exec(
sqlite3 *db, /* The database on which the SQL executes */
const char *zSql, /* The SQL to be executed */
sqlite3_callback xCallback, /* Invoke this callback routine */
void *pArg, /* First argument to xCallback() */
char **pzErrMsg /* Write error messages here */
){
int rc = SQLITE_OK;
const char *zLeftover;
sqlite3_stmt *pStmt = 0;
char **azCols = 0;

int nRetry = 0;
int nCallback;

if( zSql==0 ) return SQLITE_OK;
while( (rc==SQLITE_OK || (rc==SQLITE_SCHEMA && (++nRetry)<2)) && 
zSql[0] ){

int nCol;
char **azVals = 0;

pStmt = 0;
rc = sqlite3_prepare(db, zSql, -1, , );
assert( rc==SQLITE_OK || pStmt==0 );
if( rc!=SQLITE_OK ){
continue;
}
if( !pStmt ){
/* this happens for a comment or white-space */
zSql = zLeftover;
continue;
}

nCallback = 0;

nCol = sqlite3_column_count(pStmt);
azCols = sqliteMalloc(2*nCol*sizeof(const char *) + 1);
if( azCols==0 ){
goto exec_out;
}

while( 1 ){
int i;
rc = sqlite3_step(pStmt);

/* Invoke the callback function if required */
if( xCallback && (SQLITE_ROW==rc ||
(SQLITE_DONE==rc && !nCallback && 
db->flags_NullCallback)) ){

if( 0==nCallback ){
for(i=0; i azCols[i] = (char 

Re: [sqlite] Object Oriented Question About Adding a vector inside the callback function

2007-08-10 Thread Dennis Cote

Stephen Sutherland wrote:
okay i'm trying to use preparestatement and step and finalize. 
  I have some  quick questions about this legacy.c code. 
   
  First I notice that it has a while loop within a while loop. 
  Question: when I implement this prepared statement, will I also need a while loop within a while loop ? 
   
  Just double checking 
   
  I noticed rc = sqlite3_step(pStmt); is the start of the inner while loop. 
  I'm guessing the inner while loop is needed with pStmt contains multiple SQl statements right ? 
   
 

Stephen,

The two loops are used, as you surmised, to execute multiple SQL 
statements. The outer loop is repeated for each SQL statement in the 
input to sqlite3_exec. The inner loop is used to step through each row 
of the result of the execution of a particular statement.


In the normal case, with only a single SQL statement passed in, the 
outer loop is executed only once. The inner loop will be executed once 
for each result row. 


HTH
Dennis Cote

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Problem loading extension in Delphi (FTS2)

2007-08-10 Thread Henrik Ræder
   Hi

   I'm trying to load the FTS2 extension in Delphi, using the Aducom
components. Am really close, but still stuck, and thinking it's a problem
with the parameter to sqlite3_enable_load_extension().

In declaration:
procedure sqlite3_enable_load_extension(db: string; onoff: integer);
stdcall; far; external 'sqlite3.dll';

In code:
sqlite3_enable_load_extension(Bladbase.Database, 1);
Result2 := Bladbase.SQLite3_ExecSQL('SELECT load_extension(''libfts2.dll
'');');

   I get an exception "Not authorized" on the SQL statement, inferring that
the enable_load_extension() function failed.

   This is possibly due to it wanting a real handle to the database, which
the Aducom components don't provide in a visible manner.

   Any ideas?

   -Henrik


Re: [sqlite] When to use SQLITE_STATIC and SQLITE_TRANSIENT?

2007-08-10 Thread Dan Kennedy
On Fri, 2007-08-10 at 11:28 +0200, Jef Driesen wrote:
> When using sqlite3_bind_text() (or a similar function) with 
> SQLITE_STATIC, how long does the pointer have to remain valid? As long 
> as the sqlite3_stmt is not finalized?

Pretty much. It has to be valid during all subsequent calls to 
sqlite3_step() on the statement handle. Or until you bind a
different value to the same parameter.

So the technique below is fine.

Dan.

> 
> It is clear to me the following will cause no problem:
> 
> sqlite3_bind_text (stmt, column, "some text", -1, SQLITE_STATIC);
> 
> But what about this:
> 
> void some_func (const char* text)
> {
> sqlite3_stmt *stmt = 0;
> sqlite3_prepare_v2 (db, sql, -1, , NULL);
> sqlite3_bind_text (stmt, column, text, -1, SQLITE_STATIC);
> sqlite3_step (stmt);
> ...
> sqlite3_finalize (stmt);
> }
> 
> In this case the pointer remains unchanged as long as the statement is 
> valid, but it can change afterwards. Is that a problem and should I use 
> SQLITE_TRANSIENT here?
> 
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
> 


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] When to use SQLITE_STATIC and SQLITE_TRANSIENT?

2007-08-10 Thread Jef Driesen
When using sqlite3_bind_text() (or a similar function) with 
SQLITE_STATIC, how long does the pointer have to remain valid? As long 
as the sqlite3_stmt is not finalized?


It is clear to me the following will cause no problem:

sqlite3_bind_text (stmt, column, "some text", -1, SQLITE_STATIC);

But what about this:

void some_func (const char* text)
{
   sqlite3_stmt *stmt = 0;
   sqlite3_prepare_v2 (db, sql, -1, , NULL);
   sqlite3_bind_text (stmt, column, text, -1, SQLITE_STATIC);
   sqlite3_step (stmt);
   ...
   sqlite3_finalize (stmt);
}

In this case the pointer remains unchanged as long as the statement is 
valid, but it can change afterwards. Is that a problem and should I use 
SQLITE_TRANSIENT here?




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Can an autogenerated integer primary key become negative or zero?

2007-08-10 Thread Jef Driesen

Suppose I have a simple table with an integer primary key:

CREATE TABLE table (
id INTEGER PRIMARY KEY NOT NULL,
name TEXT
);

and insert values without supplying a value for the primary key:

INSERT INTO table (name) VALUES (@name);

Is it guaranteed that the primary key is always positive? In my
application code, I would like to reserve negative values (and possibly
zero) for special meanings, but that is only possible if they never
appear in the database.

In the documentation [1], I read the primary key is a signed integer, so
it can hold negative numbers. But the autoincrement algorithm starts
counting from 1 and thus the primary key should never become negative or
zero. Or is that not true?

[1] http://www.sqlite.org/autoinc.html



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Object Oriented Question About Adding a vector inside the callback function

2007-08-10 Thread Igor Mironchick

Hi, guys.

Dennis Cote wrote:

Stephen,

You should look into using the newer prepare/step API functions 
instead of the callback mechanism. It will make your code clearer, and 
will probably execute faster as well.


I don't think so. Prepare/step mechanism can invoke productivity of 
"INSERT" or "UPDATE", or something like this, when you have much rows to 
insert/update. But when you need to do "SELECT" sqlite3_exec - the best 
way in my opinion. Look at the code that you represent - this is the 
answer on all questions. Want you or don't, but you must allocate memory 
for result and call function in C/C++ is very cheaply operation. You 
sad: "It will make your code clearer". I don't agree. Look...


char * sql = sqlite3_mprintf( "SELECT * FROM %s", table_name );
int ret = sqlite3_exec( db, sql, callback, NULL, NULL );
sqlite3_free( sql );

What can be clearer than it???

But when you store many information in DB than transactions/prepare/step 
are more preferable for productivity. But it does not make code clearer, 
inside out...




The new API is used to implement the current version of sqlite3_exec 
that uses the  callback mechanism so you can look at that code to see 
how the new API is used. The following excerpt is from the file 
legacy.c in the sqlite source. It shows how sqlite uses the new API 
functions to build the arrays of strings it passes to the callback 
function.


By using the new API functions directly you can avoid the overhead of 
converting all the database fields into string and building these 
arrays, only to have your callback function iterate over the string 
arrays and convert the values back into other types (for non string 
fields anyway) and then stuff them into vectors. You can extract the 
fields and store them directly into the vectors you want.


And here I see this magic word "callback" :)

--
Regards,
Igor Mironchick,
Intervale ©
#ICQ 492-597-570


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] [Visual Basic] How do you work with SQLite?

2007-08-10 Thread RB Smissaert
Several reasons. Main one is that we won't be allowed as this is a third
party application clinical database. The other one is that it would cause
too much slow-down of the regular clinical front-end application.
This is reporting software and apart from some rare exceptions there is no
writing back to Interbase.

RBS

-Original Message-
From: mos [mailto:[EMAIL PROTECTED] 
Sent: 10 August 2007 02:58
To: sqlite-users@sqlite.org
Subject: RE: [sqlite] [Visual Basic] How do you work with SQLite?

At 05:25 PM 8/9/2007, you wrote:
>I use it mainly to manipulate data obtained from an Interbase database.
>All the data will eventually be dumped to Excel.
>I use 2 ways to move data from Interbase to SQLite.
>One, via an ADO recordset after connecting to Interbase with ODBC. This
>recordset will then be dumped to SQLite via the free VB wrapper from Olaf
>Schmidt, dhSQLite. Very good and fast wrapper with a rich object model.
>Two, via a custom Delphi dll that moves data directly from Interbase to
>SQLite. This is maybe slightly faster than the first method, but not that
>much difference. So, no ODBC with this method and no ADO recordset.
>
>Moving data from SQLite to Excel is all done with dhSQLite. This wrapper
can
>be downloaed from: http://www.thecommon.net/2.html
>Very much recommended for anybody who works with VB or VBA.
>
>RBS

RBS,
 So why can't you manipulate the data in Interbase? It's reasonably 
fast.

Mike 


-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Threading issues in SQLite

2007-08-10 Thread Bharath Booshan L
Hi Dan,

 Thanks for your suggestion.

> If you have any choice in the matter, don't use threads. Run all 5
> queries from the same thread. You can either run them sequentially,

Running sequentially might trouble me as I have to update more sets of
information at a cause of single event.
 
> or sqlite3_prepare() all 5 and then round-robin calls to sqlite3_step().
I have look into this. However, could you please let me know the overhead in
managing multiple connections? Does it create any impact on my application's
performance? 

On 8/10/07 11:41 AM, "Dan Kennedy" <[EMAIL PROTECTED]> wrote:

> On Fri, 2007-08-10 at 11:25 +0530, Bharath Booshan L wrote:
>> Hello All,
>> 
>>  I am using SQLite in one my application and I require to retrieve around
>> 4-5 sets of information simultaneously. I have opted to run the queries in
>> separate threads which seems obvious choice here.
>> 
>>  However, I came to know from one of the documents in sqlite.org that single
>> connection cannot be used simultaneously across threads.
>> 
>>  So I would like to hear any suggestions regarding the best wary to open &
>> manage multiple connections i.e.
>> 
>> a) Is it efficient to create new connections in separate thread each time
>> when the query needs to be executed? ( Here I am worried about the time
>> taken to open connection )
>> 
>> b) Is it efficient to create the number of connections required, in a single
>> thread and use it in different threads? ( although a connection will not be
>> used simultaneously and this will eliminate the effort to create different
>> connections but we need to ensure that a connection is used simultaneously
>> in different threads)
>> 
>> Looking forward to your suggestions,

 



---
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an 
intended recipient, please notify the sender and delete all copies. Emails to 
and from our network may be logged and monitored. This email and its 
attachments are scanned for virus by our scanners and are believed to be safe. 
However, no warranty is given that this email is free of malicious content or 
virus.



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Threading issues in SQLite

2007-08-10 Thread Dan Kennedy
On Fri, 2007-08-10 at 11:25 +0530, Bharath Booshan L wrote:
> Hello All,
> 
>  I am using SQLite in one my application and I require to retrieve around
> 4-5 sets of information simultaneously. I have opted to run the queries in
> separate threads which seems obvious choice here.
> 
>  However, I came to know from one of the documents in sqlite.org that single
> connection cannot be used simultaneously across threads.
> 
>  So I would like to hear any suggestions regarding the best wary to open &
> manage multiple connections i.e.
> 
> a) Is it efficient to create new connections in separate thread each time
> when the query needs to be executed? ( Here I am worried about the time
> taken to open connection )
> 
> b) Is it efficient to create the number of connections required, in a single
> thread and use it in different threads? ( although a connection will not be
> used simultaneously and this will eliminate the effort to create different
> connections but we need to ensure that a connection is used simultaneously
> in different threads)
> 
> Looking forward to your suggestions,

If you have any choice in the matter, don't use threads. Run all 5 
queries from the same thread. You can either run them sequentially,
or sqlite3_prepare() all 5 and then round-robin calls to sqlite3_step().

Either way, things will be more efficient. For you and the application.
Hey, you asked for suggestions. :)

Dan.




-
To unsubscribe, send email to [EMAIL PROTECTED]
-