Re: [sqlite] DeviceSQL

2007-12-14 Thread Nicolas Williams
On Fri, Dec 14, 2007 at 03:38:17PM +, [EMAIL PROTECTED] wrote: > That would be the Serialized Statement Extension, SSE. > The SSE provides the programmer with two new APIs: Would it be useful to generate human-readable VDBE "assemply"? Or, how do you develop parser changes that involve new

Re: [sqlite] Equivalent syntax?

2007-01-31 Thread Nicolas Williams
On Wed, Jan 31, 2007 at 06:31:20PM -0500, Anderson, James H (IT) wrote: > Is cast documented on the sqlite website? I couldn't find it. http://www.sqlite.org/ Click on 'syntax', click on 'expression', arrive at: http://www.sqlite.org/lang_expr.html

Re: [sqlite] UNIQUE constraint on column

2007-01-31 Thread Nicolas Williams
On Wed, Jan 31, 2007 at 05:23:29PM -0500, Shane Harrelson wrote: > > I have two tables, an "Objects" table with a foreign key into a second > "Strings" table which is composed of unique values. It is a many to > one relationship, that is, several Objects may reference the same > String. When

Re: [sqlite] Re: Re: Re: selecting a random record from a table

2007-01-26 Thread Nicolas Williams
On Fri, Jan 26, 2007 at 01:38:07PM -0500, Igor Tandetnik wrote: > Nicolas Williams <[EMAIL PROTECTED]> wrote: > >But I read that as "goto to offset 2 and return the first row after > >offset 2." > > Why offset 2, when the clause reads, say, OFFSET 500? Also,

Re: [sqlite] Re: Re: selecting a random record from a table

2007-01-26 Thread Nicolas Williams
On Fri, Jan 26, 2007 at 12:58:13PM -0500, Igor Tandetnik wrote: > Nicolas Williams <[EMAIL PROTECTED]> wrote: > >I can't see why this doesn't work reliably, but if it did it would be > >O(1). > > Imagine that you have just two records in your table, with ROWIDs of

Re: [sqlite] Re: selecting a random record from a table

2007-01-26 Thread Nicolas Williams
On Fri, Jan 26, 2007 at 09:16:41AM -0700, Dennis Cote wrote: > The offset mechanism proposed by Igor earlier is far more efficient as > long as you know the size of the table. You can always get the size from > a count query, which also requires a table scan, but even that is less > expensive

Re: [sqlite] How to conditionally drop a table?

2007-01-25 Thread Nicolas Williams
On Thu, Jan 25, 2007 at 10:35:23AM -0500, Anderson, James H (IT) wrote: > I need a way to drop a table only if that table exists. How would I do > that? You'd think this would work: SELECT CASE WHEN (SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name = 'foo') > 0

Re: [sqlite] SQLite last inserted id

2007-01-22 Thread Nicolas Williams
If you'd have a unique index on that column then you could just use "INSERT OR IGNORE ..." Nico -- - To unsubscribe, send email to [EMAIL PROTECTED]

Re: [sqlite] Pager Question... Open Source Project

2007-01-22 Thread Nicolas Williams
On Mon, Jan 22, 2007 at 06:06:53PM -0600, John Stanton wrote: > Alternately use a 64 bit machine and a 64 bit OS. Did you not read what I wrote? That was one of the solutions I offered. The issue is that memory mapping runs into the 32-bit VM space wall and you have three options: too bad, go

Re: [sqlite] Pager Question... Open Source Project

2007-01-22 Thread Nicolas Williams
On Mon, Jan 22, 2007 at 05:13:44PM -0600, John Stanton wrote: > >Of course. The point is that 32-bit memory models will impact the > >design of the this pager. Either only support 64-bit memory models, > >window your memory mappings, or only support small databases. > > > Or be adaptive and

Re: [sqlite] Pager Question... Open Source Project

2007-01-22 Thread Nicolas Williams
On Mon, Jan 22, 2007 at 09:59:56AM -0600, John Stanton wrote: > A neat way to implement a pager is to memory map a file to make it > shared virtual memory. Then you need some form of mutex to synchronize > access to it. If you are sharing it between processes or threads you > need a lock flag

Re: [sqlite] File db to memory db and back

2007-01-18 Thread Nicolas Williams
On Fri, Jan 19, 2007 at 12:51:36AM +0100, Nemanja Corlija wrote: > On 1/19/07, Nicolas Williams <[EMAIL PROTECTED]> wrote: > >Why don't you use a trigger to duplicate INSERTs into the memory db to > >the disk db? > > > Nicolas, thanks for the idea. Didn't really

Re: [sqlite] Re: How to optimize a select that gets 17 rows from a 700k row DB (via perl using DBI)?

2007-01-16 Thread Nicolas Williams
On Sat, Jan 13, 2007 at 06:35:20PM -0500, [EMAIL PROTECTED] wrote: > I guess that's the trick, to have the "current" or at least "recent" > database and then the historical one. As of now, the process of polling > the 17 machines takes about 40 seconds or so (when I first started running > the

Re: [sqlite] How to optimize a select that gets 17 rows from a 700k row DB (via perl using DBI)?

2007-01-13 Thread Nicolas Williams
On Sat, Jan 13, 2007 at 12:57:43AM -0500, [EMAIL PROTECTED] wrote: > The SQLite database > is INSERTed into because I want to keep historical data. The rationale > for this is explained later. For your main application (finding the least

Re: [sqlite] Sqlite design question

2007-01-09 Thread Nicolas Williams
On Tue, Jan 09, 2007 at 01:28:21PM +0100, Florian Weimer wrote: > If your database isn't too large, and you aren't running on Windows, > you could make a copy of the database before updating it, so that > readers and the writer work on different databases. I wish ZFS would allow one to

Re: [sqlite] attach in transaction

2007-01-08 Thread Nicolas Williams
On Mon, Jan 08, 2007 at 03:42:47PM +, [EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > Can someone tell me why attach cannot be called within transaction? > > I do not recall. > > Clearly a DETACH will not work inside a transaction if the > table being detached has been accessed or

Re: [sqlite] how would you allow users to re-order rows arbitrarily?

2007-01-07 Thread Nicolas Williams
On Sat, Jan 06, 2007 at 09:53:39PM -0800, Sean Payne wrote: > Suppose gui-users wanted to drag and drop rows in a table so that > they could shuffle it anyway that they wanted so that the rows > maintained that order the next time they accessed the table. Can > this be done without

Re: [sqlite] sqlite performance, locking & threading

2007-01-03 Thread Nicolas Williams
On Thu, Jan 04, 2007 at 12:50:01AM +, Emerson Clarke wrote: > My oppologies, your right that explanation had been given. OK. > But i didnt actually take it seriously, i guess i found it hard to > believe that it being the easier option was the only reason why this > limitation was in place.

Re: [sqlite] sqlite performance, locking & threading

2007-01-03 Thread Nicolas Williams
On Tue, Jan 02, 2007 at 11:56:42PM +, Emerson Clarke wrote: > The single connection multiple thread alternative apparently has > problems with sqlite3_step being active on more than one thread at the > same moment, so cannot easily be used in a safe way. But it is by far > the fastest and

Re: [sqlite] sqlite performance, locking & threading

2007-01-02 Thread Nicolas Williams
On Sat, Dec 30, 2006 at 03:34:01PM +, Emerson Clarke wrote: > Technically sqlite is not thread safe. [...] Solaris man pages describe APIs with requirements like SQLite's as "MT-Safe with exceptions" and the exceptions are listed in the man page. That's still MT-Safe, but the caller has to

Re: [sqlite] delayed (batch) transactions

2006-12-26 Thread Nicolas Williams
On Tue, Dec 26, 2006 at 09:36:42AM -0800, Ken wrote: > > Your question boils down to this: Can you speed up transactions > > by dropping the durable property - the D in ACID. Yes you > > can. Actually, most client/server database engines already > > do this for you without telling you. Very few

Re: [sqlite] delayed (batch) transactions

2006-12-20 Thread Nicolas Williams
On Wed, Dec 20, 2006 at 01:22:06PM -0500, Laszlo Elteto wrote: > Nested transactions would solve my problem - but only if it worked across > different connections. As I said there are many transactions from various > clients, they may use multiple connections (eg. on a server). I think nested >

Re: [sqlite] delayed (batch) transactions

2006-12-20 Thread Nicolas Williams
On Wed, Dec 20, 2006 at 02:01:12AM +, [EMAIL PROTECTED] wrote: > Laszlo Elteto <[EMAIL PROTECTED]> wrote: > > I DO need Durability, so I don't want to drop that. In fact, I need and want > > normal transactional updates - just not immediately flushed to disk. > > If the information is not

Re: [sqlite] Re: File Syste

2006-12-13 Thread Nicolas Williams
On Wed, Dec 13, 2006 at 05:03:50PM -0400, Cesar Rodas wrote: > On 13/12/06, John Stanton <[EMAIL PROTECTED]> wrote: > > > >It is hard to imagine why you would want to use Sqlite B-Tree access. > > I am developing a File System, and I'd like to use B+ Tree and not lost time > and CPU understanding

Re: [sqlite] Re: Check for empty table

2006-12-13 Thread Nicolas Williams
On Wed, Dec 13, 2006 at 01:33:35PM -0500, Igor Tandetnik wrote: > Nicolas Williams <[EMAIL PROTECTED]> wrote: > >On Wed, Dec 13, 2006 at 06:07:56PM +, RB Smissaert wrote: > >count(*) doesn't read every record in the table. > > Does too. Run EXPLAIN and see for you

Re: [sqlite] Check for empty table

2006-12-13 Thread Nicolas Williams
On Wed, Dec 13, 2006 at 06:07:56PM +, RB Smissaert wrote: > Nothing wrong, but is it the fastest? count(*) doesn't read every record in the table. - To unsubscribe, send email to [EMAIL PROTECTED]

Re: [sqlite] a question about muticonnection

2006-12-06 Thread Nicolas Williams
On Wed, Dec 06, 2006 at 12:51:29PM -0600, John Stanton wrote: > To fully handle the situation you need to know how many users have a > transaction pending and are pondering ordering the item. That requires > some form of journal or "committed" total. If you have three items and > there are

Re: [sqlite] a question about muticonnection

2006-12-06 Thread Nicolas Williams
On Wed, Dec 06, 2006 at 11:36:11AM -0600, John Stanton wrote: > I fully understood. It is an age old problem that has puzzled > generations of system designers. My first exposure was over thirty > years ago. The approach we discovered worked was to treat it as a > transaction in the logical

Re: [sqlite] Re: Unicode Help

2006-12-06 Thread Nicolas Williams
On Wed, Dec 06, 2006 at 10:06:12AM -0600, John Stanton wrote: > Marten Feldtmann wrote: > >But Tcl is not part of SQLite (and this is good) - this is just an > >add-on. The idea with the > >additional functions are pretty good ! > > > How does Sqlite become Sqbloated? By function creep, one

Re: [sqlite] a question about muticonnection

2006-12-06 Thread Nicolas Williams
On Wed, Dec 06, 2006 at 10:04:42AM -0600, John Stanton wrote: > hongdong wrote: > >I just have a base question: > >assume user A and user B now both connection to a same database and both of > >them want to update a same record,but only one is allowed > >in this condition: > >A begin to browse

Re: [sqlite] Re: Unicode Help

2006-12-05 Thread Nicolas Williams
On Tue, Dec 05, 2006 at 06:53:28PM +0100, Marten Feldtmann wrote: > Perhaps it would be nice to change sqlite3 in that way, that (when columns > with storage class text) these columns are converted to the host platform > code page. But actually even in that situation you may have strings, which >

Re: [sqlite] Re: Re: ip2long

2006-12-05 Thread Nicolas Williams
On Tue, Dec 05, 2006 at 09:58:02AM -0700, Dennis Cote wrote: > select >case >when substr(ip, 2, 1) = '.' then -- one digit first quad >case >when substr(ip, 4, 1) = '.' then -- 1 digit second quad >case >when substr(ip, 6, 1) = '.' then -- 1 digit

Re: [sqlite] Re: Re: ip2long

2006-12-05 Thread Nicolas Williams
On Tue, Dec 05, 2006 at 08:21:35PM +1100, Kevin Waterson wrote: > This one time, at band camp, "Trevor Talbot" <[EMAIL PROTECTED]> wrote: > > > > I'd store the IPs in the DB in integer form as Lloyd suggested, if > > range queries are your goal. Do conversion to and from display format > > in

Re: [sqlite] Dealing with dates in the format yyyymmdd

2006-12-04 Thread Nicolas Williams
On Sun, Dec 03, 2006 at 05:31:55PM +, RB Smissaert wrote: > Still have the problem though how to compare dates in SQLite when the format > is the integer mmdd. Maybe I will need some custom SQLite function. What's difficult about comparing integers of the form mmdd? Comparing them is

Re: [sqlite] Batching functions

2006-12-04 Thread Nicolas Williams
On Sun, Dec 03, 2006 at 11:24:36PM -0600, John Stanton wrote: > How about running a daemon on your machine which gets the request from > your user defined function, does the lookup with a persistent connection > and asynchronously updates the row in the DB? It does not need to be a > daemon,

[sqlite] Batching functions

2006-12-03 Thread Nicolas Williams
Suppose I want to add a user-defined function that may perform remote lookups. E.g., a function that maps user names, e-mail addresses, or what have you to internal ID forms (SIDs, POSIX UIDs, GUIDs, etc...) by asking a remote server to perform this mapping. Now suppose I wanted to do something

Re: [sqlite] Preallocating fixed disk space for database ...

2006-12-01 Thread Nicolas Williams
On Fri, Dec 01, 2006 at 08:35:24AM +0100, kamil wrote: > I want to preallocate disk space for database. I have only one table with ~1 > milion entries, each entry takes about 30 bytes. Entries are added/removed > but there is some maximum number of items, which can be put into the table > at

Re: [sqlite] Re: sqlite_open

2006-12-01 Thread Nicolas Williams
On Thu, Nov 30, 2006 at 10:52:55PM -0600, John Stanton wrote: > Sqlite has a carefully thought through minimalism. Feature creep would > detract from its function as a small footprint, embedded DB. If you > want different features there is nothing to stop you adding your own > library

Re: [sqlite] Query on database operations.

2006-11-30 Thread Nicolas Williams
On Thu, Nov 30, 2006 at 08:03:00PM +0530, Kalyani Tummala wrote: > With indexes on every column(searched), the following is the heap size > for different database operations on a database with 100 records and 6 > tables with an avg of 10 to 15 fields each. You can probably get by quite well

Re: [sqlite] Accommodating 'Insert' and 'Update'

2006-11-28 Thread Nicolas Williams
On Tue, Nov 28, 2006 at 03:03:58PM -0600, Isaac Raway wrote: > Use an index on the table with your key values and call "INSERT OR > UPDATE INTO t(...) VALUES(...)" for all creation and update > operations. Unless you're dealing with a tremendous amount of data per > record this will be perfectly

Re: [sqlite] Music Files

2006-11-27 Thread Nicolas Williams
On Mon, Nov 27, 2006 at 02:40:44PM -0600, John Stanton wrote: > You store them in the DB as a BLOB type, but save the data as a JPEG, > MP3, WAV or whatever it happens to be. The binary data resides as a DB > column and the same row may have other columns which could be text to > describe the

Re: [sqlite] Using BLOBs in where fields

2006-11-03 Thread Nicolas Williams
On Fri, Nov 03, 2006 at 11:39:47AM -0600, Gabriel Cook wrote: > So, is there any way to of thing with a BLOB? > > > WHERE substr(data, 1, 1) == x'bc' This works: WHERE substr(data, 1, 1) == CAST(X'...' AS TEXT); but only as long as X'...' has no NULs. And probably only as lon as data contains

<    1   2   3