Re: [sqlite] Need help on build query.

2007-02-12 Thread drh
Igor Tandetnik [EMAIL PROTECTED] wrote: Artem Yankovskiy ayankovskiy-/[EMAIL PROTECTED] wrote: I know about DROP TABLE. I have not knew when compatibility DROP TABLE and SELECT... DROP TABLE (select name from sqlite_master where...) did not work. Can I build resembling query?

RE: [sqlite] Backing up a SQlite database

2007-02-12 Thread Brandon, Nicholas \(UK\)
Derrell, Just to clarify, you don't need to use an exclusive transaction. That will acquire a write lock and unnecessarily block all other readers as well. You only need to hold a read lock to prevent any other process from acquiring a write lock. Dennis Cote I asked a similar question last

Re: [sqlite] Multiple prepared queries

2007-02-12 Thread Wesley W. Terpstra
Thanks for your answers! On Feb 12, 2007, at 1:58 AM, [EMAIL PROTECTED] wrote: Wesley W. Terpstra [EMAIL PROTECTED] wrote: Suppose you have two prepared queries: q1 and q2. I currently believe that it is an error to execute: step q1, step q2, step q1. No. Queries can be interleaved this

Re: [sqlite] Multiple prepared queries

2007-02-12 Thread John Stanton
Prepared queries are actually the query compiled into the metalanguage, VDBE. You can have many statements in one transaction, and each of those statements can be reusing a VDBE virtual machine instance with a current set of data bound to it. When you reset the compiled statement you make it

Re: [sqlite] Need help on build query.

2007-02-12 Thread Jay Sprenkle
On 2/12/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Igor is correct - you cannot do that now. But I have sometimes wondered if it would be nice to add an exec() function to SQLite that would recursively invoke its argument as an SQL script. For example: SELECT exec('DELETE FROM ' ||

Re: [sqlite] Multiple prepared queries

2007-02-12 Thread Wesley W. Terpstra
On Feb 12, 2007, at 1:21 AM, John Stanton wrote: Prepared queries are actually the query compiled into the metalanguage, VDBE. You can have many statements in one transaction, and each of those statements can be reusing a VDBE virtual machine instance with a current set of data bound to

Re: [sqlite] Need help on build query.

2007-02-12 Thread drh
Jay Sprenkle [EMAIL PROTECTED] wrote: On 2/12/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Igor is correct - you cannot do that now. But I have sometimes wondered if it would be nice to add an exec() function to SQLite that would recursively invoke its argument as an SQL script.

Re: [sqlite] Multiple prepared queries

2007-02-12 Thread John Stanton
Wesley W. Terpstra wrote: On Feb 12, 2007, at 1:21 AM, John Stanton wrote: Prepared queries are actually the query compiled into the metalanguage, VDBE. You can have many statements in one transaction, and each of those statements can be reusing a VDBE virtual machine instance with a

Re: [sqlite] Appropriate uses for SQLite

2007-02-12 Thread Mike Owens
Hey, sorry I'm a little late on this one (as usual). On 2/3/07, David M X Green [EMAIL PROTECTED] wrote: I am new to this but are these issues those of trying to get it to do what sqlite it is not designed for. I quote the book The Definitive Guide to SQLite - Chapter 1 --- Networking

[sqlite] INTEGER PRIMARY KEY

2007-02-12 Thread Tom Shaw
Here's a question on INTEGER PRIMARY KEY. I would like use IP addresses (converted to an unsigned number to man them monotonically increasing) for INTEGER PRIMARY KEY however I can't determine from the online docs whether if I supply an unsigned integer in PHP 5: $uip = sprintf(%u,

Re: [sqlite] Multiple prepared queries

2007-02-12 Thread Wesley W. Terpstra
On Feb 12, 2007, at 3:22 PM, John Stanton wrote: Look at how Sqlite implements callbacks in sqlite3_exec to discover a way to implement your language. I had already looked at it. I will be using the prepare_v2/bind/step/ reset/.../finalize interface instead. The exec interface is too

[sqlite] Performance problem with simple queries

2007-02-12 Thread Makavy, Erez \(Erez\)
Problem summery: --- Simple queries sometimes take ~400 ms Analysis: --- - A php script runs the same SQL query several times in different places (in different transactions). Some of the queries take around 400ms while the others (identical queries) takes only 4-20ms.

Re: [sqlite] Performance problem with simple queries

2007-02-12 Thread John Stanton
You are almost certainly encountering disk cacheing effects. Makavy, Erez (Erez) wrote: Problem summery: --- Simple queries sometimes take ~400 ms Analysis: --- - A php script runs the same SQL query several times in different places (in different transactions).

Re: [sqlite] Multiple prepared queries

2007-02-12 Thread Dennis Cote
Wesley W. Terpstra wrote: val Iterator1a = SQL.execute Query1 (parameter1 2) val Iterator1b = SQL.execute Query1 (foobar 3) val Iterator2 = SQL.execute Query2 4 case Iterator1a () of NONE = print End of this table | SOME (x y) = print (Got a row: ^ x ^ , ^ Int.toString y ^ \n)

Re: [sqlite] Multiple prepared queries

2007-02-12 Thread John Stanton
I wasn't suggesting that you use sqlite3_exec. On the contrary I would counsel you not to. I just suggested that you look to see how it implements callbacks and that you implement a callback to handle each row. Then the logic of your interface is elegant. If you are creating a language

Re: [sqlite] Multiple prepared queries

2007-02-12 Thread Wesley W. Terpstra
On Feb 12, 2007, at 7:32 PM, John Stanton wrote: I suggest that you also look carefully at the manifest typing implemented in Sqlite. If your language is strongly typed you will have some design issues to address. I am aware of this issue and already have a solution. It's part of why I

[sqlite] Atomically creating a database and bootstrapping its tables

2007-02-12 Thread Ron Stevens
I have two processes trying to access a database for the first time at roughly the same time. I'm wondering if it's possible to atomically create a database and bootstrap it with some tables from one process so that the other process doesn't open the database either before SQLite has finished

Re: [sqlite] Atomically creating a database and bootstrapping its tables

2007-02-12 Thread Ken
To bootstrap my db's I create a database template. Then make a physical copy of that. Locking and access is done via flock. So the first process to gain the lock wins and is respoonsible for making the copy, the other just waits until the lock is released and then connects. I make lots of

Re: [sqlite] Multiple prepared queries

2007-02-12 Thread John Stanton
The basis of our business has been writing compilers and run time packages to integrate legacy and newer software. We discovered that basic computer science provides the answers and looking beyond the paradigm of the legacy language or system is essential if a complexity chain reaction is to

[sqlite] Performance Question

2007-02-12 Thread Slater, Chad
Hello, I'm having trouble with the performance of one of my queries and my sql kung fu is limited. Any help with this problem would be greatly appreciated Here's a stripped down version of the tables I'm dealing with: CREATE TABLE A ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT )

Re: [sqlite] Atomically creating a database and bootstrapping its tables

2007-02-12 Thread Dennis Cote
Ron Stevens wrote: In general, does SQLite protect against the database being opened while it's being created so other processes don't open it assuming everything is in a good state? Ron, No, you have to do that in your application. In pseudo code your create function could do this:

Re: [sqlite] Performance Question

2007-02-12 Thread Dennis Cote
Slater, Chad wrote: Hello, I'm having trouble with the performance of one of my queries and my sql kung fu is limited. Any help with this problem would be greatly appreciated Here's a stripped down version of the tables I'm dealing with: CREATE TABLE A ( id INTEGER PRIMARY KEY

RE: [sqlite] Performance Question

2007-02-12 Thread Slater, Chad
I overly simplified my example. I'm actually selecting columns from table B and C which is why I had this in the where clause: AND ( JoinAToB.B_id = B.id ) AND ( JoinAToB.A_id = A.id ) ... Converting those to explicit JOIN clauses fixed the problem. Thanks for your help! -Original

Re: [sqlite] Multiple prepared queries

2007-02-12 Thread Wesley W. Terpstra
For anyone who has the same questions I had, I've found most of the answers. PS. Excellent internal documentation of the VDBE (though a bit out-of- date)! It made it really easy to navigate the source. On Feb 12, 2007, at 1:51 PM, Wesley W. Terpstra wrote: What is the defined behaviour of

Re: Re: [sqlite] Need help on build query.

2007-02-12 Thread Artem Yankovskiy
Thanks --- [EMAIL PROTECTED] wrote: Igor Tandetnik [EMAIL PROTECTED] wrote: Artem Yankovskiy ayankovskiy-/[EMAIL PROTECTED] wrote: I know about DROP TABLE. I have not knew when compatibility DROP TABLE and SELECT... DROP TABLE (select name from sqlite_master where...)