Re: [sqlite] Is this a bug?

2008-07-03 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Alex Katebi wrote: > sqlite3_errmsg(db) does not provide the correct error message but > sqlite_exec(...) does. The message gets cleared on various calls so you'll want to get it as early as possible after knowing there is an error. For example

[sqlite] Is this a bug?

2008-07-03 Thread Alex Katebi
sqlite3_errmsg(db) does not provide the correct error message but sqlite_exec(...) does. I have attached my test code. You can compile it by doing below: gcc x.c -lsqlite3 ___ sqlite-users mailing list sqlite-users@sqlite.org

Re: [sqlite] delete to leave x rows per group

2008-07-03 Thread RB Smissaert
Thanks, nice and simple. I had come up with something that works as well, but probably more complex than needed. This is with my actual data: delete from sqlite_tablePa where rowid not in (select rowid from sqlite_tablePa where (select count(*) from sqlite_tablePa as s where s.patient_id

Re: [sqlite] Spatial data in SQLite

2008-07-03 Thread Stephen Woodbridge
Alexey Pechnikov wrote: > Hello! > > I found article about spatial extensions for SQLite > http://www.perrygeo.net/wordpress/?p=115 > > Do you know other GIS extensions? I'm migrating from PostgreSQL+PostGIS to > SQLite and searching GIS extensions for SQLIte.

Re: [sqlite] delete to leave x rows per group

2008-07-03 Thread Igor Tandetnik
RB Smissaert <[EMAIL PROTECTED]> wrote: > Can this be done in SQLite SQL? > > ID Value > --- > 1 A > 1 B > 1 C > 1 D > 1 E > 2 A > 2 B > 2 C > 2 D > 2 E > 2 F > > Delete rows to leave x rows per ID, say 3 rows, so we get: delete from tableName where rowid not in ( select rowid

[sqlite] delete to leave x rows per group

2008-07-03 Thread RB Smissaert
Can this be done in SQLite SQL? ID Value --- 1 A 1 B 1 C 1 D 1 E 2 A 2 B 2 C 2 D 2 E 2 F Delete rows to leave x rows per ID, say 3 rows, so we get: ID Value --- 1 C 1 D 1 E 2

Re: [sqlite] Update static database with records from memory database.

2008-07-03 Thread Pejayuk
Thankyou Dennis. You have been a fantastic help. I will be sure to put credits in my script to you all. I am hoping to release this ranking system after its run for a month or so. Eventscripts is free and so are the scripts that get released. I am sure a lot of Counter Strike Source game

Re: [sqlite] Update static database with records from memory database.

2008-07-03 Thread Dennis Cote
Pejayuk wrote: > Thanks Dennis, > I get the gist of it. > > I am getting duplicate records though using insert or replace. > I was using update before. > >>From the TOP. > > When my script loads it does the following fine. > //Open static database. > es_xsql open stats_static |zmstats > //Open

Re: [sqlite] Fuzzy Matching

2008-07-03 Thread Martin Pfeifle
Hi, I think there is nothing available except FTS. Doing a full table scan and computing for each string the (Levenstein) distance to the query object is too time consuming. So what I would like to see is the implementation of a generic metric index which needs as one parameter a metric distance

Re: [sqlite] Fuzzy Matching

2008-07-03 Thread John Stanton
I believe Sqlite implemens Soundex as standard. Thet might work for you. Alberto Simões wrote: > Hello > > Although I am quite certain that the answer is that SQLite does not > provide any mechanism to help me on this, it doesn't hurt to ask. Who > know if anybody have any suggestion. > >

Re: [sqlite] Update static database with records from memory database.

2008-07-03 Thread Pejayuk
Thanks Dennis, I get the gist of it. I am getting duplicate records though using insert or replace. I was using update before. >From the TOP. When my script loads it does the following fine. //Open static database. es_xsql open stats_static |zmstats //Open memory database. es_xsql open

[sqlite] Fuzzy Matching

2008-07-03 Thread Alberto Simões
Hello Although I am quite certain that the answer is that SQLite does not provide any mechanism to help me on this, it doesn't hurt to ask. Who know if anybody have any suggestion. Basically, I am using SQLite for a dictionary, and I want to let the user do fuzzy searches. OK, some simple

[sqlite] Admin tool

2008-07-03 Thread Henrik Bechmann
Can anyone recommend an SQLite admin tool that operates on a remote database (ie desktop or browser tool that operates directly on webserver file)? Thanks! - Henrik -- Henrik Bechmann bechmann.ca Webmaster, celos.ca webhosting services ___

Re: [sqlite] Spatial data in SQLite

2008-07-03 Thread P Kishor
On 7/3/08, Alexey Pechnikov <[EMAIL PROTECTED]> wrote: > Hello! > > I found article about spatial extensions for SQLite > http://www.perrygeo.net/wordpress/?p=115 > > Do you know other GIS extensions? I'm migrating from PostgreSQL+PostGIS to > SQLite and searching GIS extensions for SQLIte. >

Re: [sqlite] sqlite3 3.5.9 floating point division seems odd

2008-07-03 Thread Tom Epperly
When I tried reproducing this behavior on a Red Hat box, the 3.5.9 version gave the expected results, so I guess it is a Debian unstable specific issue. Tom Tom Epperly wrote: > I reported this to Debian here: > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=488864 > It seems like an

[sqlite] sqlite3 3.5.9 floating point division seems odd

2008-07-03 Thread Tom Epperly
I reported this to Debian here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=488864 It seems like an upstream sqlite3 issue. I downloaded http://www.sqlite.org/sqlite-amalgamation-3.5.9.tar.gz /tmp/sqlite-amalgamation-3.5.9]> ./configure --disable-shared /tmp/sqlite-amalgamation-3.5.9]> make

Re: [sqlite] prepackaged sql statement

2008-07-03 Thread Igor Tandetnik
Henrik Bechmann <[EMAIL PROTECTED]> wrote: > My purpose was to find the least intrusive way of implementing > vertical partitioning as a security measure, for example allowing a > vendor to only see his/her records in a billing table. My idea was > that a view constrained by a condition on a

Re: [sqlite] prepackaged sql statement

2008-07-03 Thread Henrik Bechmann
My purpose was to find the least intrusive way of implementing vertical partitioning as a security measure, for example allowing a vendor to only see his/her records in a billing table. My idea was that a view constrained by a condition on a foreign key would work. In the absence of passing in

Re: [sqlite] counting tables

2008-07-03 Thread Dennis Cote
Tim Streater wrote: > > I have a PHP script that I run in Terminal under OS X, which opens an > sqlite db and works on it. Trouble is, if the db doesn't exist then > the PHP library silently creates an empty db with the given name. > Given this, I need to detect that the empty db has been

Re: [sqlite] Simple problem ?

2008-07-03 Thread c.panel
> In each row, do you want balance before that row's credit/debit has > taken place, or after? <= does the latter, < would do the former. yes, I understand. > My statement never uses any previous value of ACCOUNT field, null or > otherwise. yes of course, how stupid of me ! thanks a lot

Re: [sqlite] counting tables

2008-07-03 Thread Igor Tandetnik
Tim Streater <[EMAIL PROTECTED]> wrote: > As a work around I thought I might check that the newly opened db has > no tables, and clean up if so. My question is, what query can I make > of the db to determine that it has no tables? select exists (select * from sqlite_master where type='table');

Re: [sqlite] Simple problem ?

2008-07-03 Thread Igor Tandetnik
c.panel <[EMAIL PROTECTED]> wrote: > Good ! I've not seen like this ! > but why "where t2.DATE <= mytable.DATE" instead of where "t2.DATE < > mytable.DATE" In each row, do you want balance before that row's credit/debit has taken place, or after? <= does the latter, < would do the former. >

Re: [sqlite] counting tables

2008-07-03 Thread Stephen Woodbridge
Tim Streater wrote: > Hi, > > I have a PHP script that I run in Terminal under OS X, which opens an sqlite > db and works on it. Trouble is, if the db doesn't exist then the PHP library > silently creates an empty db with the given name. Given this, I need to > detect that the empty db has >

Re: [sqlite] counting tables

2008-07-03 Thread Simon Davies
Hi Tim, select count(*) from sqlite_master; will return 0 on a brand new db Rgds, Simon 2008/7/3 Tim Streater <[EMAIL PROTECTED]>: > Hi, > > I have a PHP script that I run in Terminal under OS X, which opens an sqlite > db and works on it. Trouble is, if the db doesn't exist then the PHP

[sqlite] counting tables

2008-07-03 Thread Tim Streater
Hi, I have a PHP script that I run in Terminal under OS X, which opens an sqlite db and works on it. Trouble is, if the db doesn't exist then the PHP library silently creates an empty db with the given name. Given this, I need to detect that the empty db has been created, delete it, and exit.

Re: [sqlite] Simple problem ?

2008-07-03 Thread c.panel
thank you. But I have a question : is rowid growing with dates ? I believed that rowid is the original order, not the index order (???). I'm going to look at this. Samuel Neff wrote: > > you can do it with a subquery, like > > select o.date, (select sum(credit - debit) from bank i where

Re: [sqlite] Simple problem ?

2008-07-03 Thread c.panel
Good ! I've not seen like this ! but why "where t2.DATE <= mytable.DATE" instead of where "t2.DATE < mytable.DATE" because what about if ACCOUNT soon exists with no null value and you want to update? Igor Tandetnik wrote: > > c.panel <[EMAIL PROTECTED]> wrote: >> one example: >> Suppose I have

Re: [sqlite] Index and ORDER BY

2008-07-03 Thread Noah Hart
Richard, Just a suggestion. Would it make sense to ask one of your document maintainers to add something similar to your explanation and add it to the "SELECT" documentation page as a note to using the WHERE clause and the "INDEX" documentation page

Re: [sqlite] Simple problem ?

2008-07-03 Thread Igor Tandetnik
c.panel <[EMAIL PROTECTED]> wrote: > one example: > Suppose I have a table with column DATE, CREDIT, DEBIT > I want to create a new column that is the balance of account > (ACCOUNT). > My first approach is to index the table on dates, then starting with > 0, then ACCOUNT = preceding ACCOUNT +

Re: [sqlite] Simple problem ?

2008-07-03 Thread Samuel Neff
you can do it with a subquery, like select o.date, (select sum(credit - debit) from bank i where i.rowid < o.rowid) from bank o order by rowid; but it would be _much_ more efficient to handle it in your host application as you loop through the data. Notice that I used rowid instead of date

[sqlite] Simple problem ?

2008-07-03 Thread c.panel
Hello, I'm learning SQL and have some difficulties to resolve some simple problems with SQL. one example: Suppose I have a table with column DATE, CREDIT, DEBIT I want to create a new column that is the balance of account (ACCOUNT). My first approach is to index the table on dates, then starting

[sqlite] Issues with sqlite3_release_memory

2008-07-03 Thread Srinivasa Ragavan
Guys, Im facing a wierd issue when thread 1 is doing a sqlite3_exec and if thread 2 attempts to call sqlite3_release_memory, the thread1 never returns from sqlite3_exec? It seems to take 100% cpu forever. Any suggestion, on how the memory should be freed or are there any guidelines on how to use

Re: [sqlite] String is changing after inserting into database

2008-07-03 Thread Harish Dixit
Hello friends, I came across a new problem. My database is currupted. When i ran the integrity check then i found the following results: *Is there any tool available which can repair it?* *Result:* RecNointegrity_check 1*** in database main *** On tree page 581 cell 1: invalid page

Re: [sqlite] validate SQL Statement

2008-07-03 Thread Umaa Krishnan
Well, I assume SQLPrepare allocates and locks appropriate resources. I need to only check the sanity of the statement, and then discard. So I was wondering if there was a way to do it, instead of prepare statement --- On Thu, 7/3/08, D. Richard Hipp <[EMAIL PROTECTED]> wrote: From: D. Richard

Re: [sqlite] validate SQL Statement

2008-07-03 Thread Alex Katebi
You can use sqlite3_complete. It does not check the grammar. It just makes makes sure that command has a semicolin. Why you need grammar checking? On Wed, Jul 2, 2008 at 11:03 PM, Umaa Krishnan <[EMAIL PROTECTED]> wrote: > Hello, > > I was wondering if there a way in sqlite, wherein I could

Re: [sqlite] SQLite database problem

2008-07-03 Thread Dennis Cote
Harish Dixit wrote: > > Is there any tool to repair the database > No. You will have to rely on your backups. If you have no backups, you may be able to retrieve some data from your tables by using the .dump command in the sqlite shell. Try dumping individual tables. Dennis Cote

Re: [sqlite] Three LEFT JOIN issues

2008-07-03 Thread Csaba
On Thu, Jul 3, 2008 at 1:33 PM, Igor Tandetnik <[EMAIL PROTECTED]> wrote: > "Csaba" <[EMAIL PROTECTED]> wrote in > message > news:[EMAIL PROTECTED] >> SELECT * FROM Words >> GROUP BY Id, Lang >> HAVING Rev=Max(Rev) > > This wouldn't do what you think it does. HAVING clause applies to the > whole

Re: [sqlite] Three LEFT JOIN issues

2008-07-03 Thread Igor Tandetnik
"Csaba" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > SELECT * FROM Words > GROUP BY Id, Lang > HAVING Rev=Max(Rev) This wouldn't do what you think it does. HAVING clause applies to the whole group, not to individual rows. It determines whether the group makes it into final

Re: [sqlite] Three LEFT JOIN issues

2008-07-03 Thread Igor Tandetnik
"Csaba" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > However, MySQL (at least this is what I recollect from about > 4 years ago) takes the tack that it will provide a 'representative' > row from each such class where no aggregate function is > specified for a non GROUP BY field >

[sqlite] SQLite database problem

2008-07-03 Thread Harish Dixit
Hello friends, I did the integrity check on the given db3 file. Here are the results: Is there any tool to repair the database RecNointegrity_check 1*** in database main *** On tree page 581 cell 1: invalid page number 1711301632 On tree page 581 cell 2: invalid page number 956314624 On

Re: [sqlite] Three LEFT JOIN issues

2008-07-03 Thread Csaba
> As this applies to my query, it would be: > SELECT * FROM Words > GROUP BY Id, Lang, Rev > HAVING Rev=Max(Rev) Drat. That Rev shouldn't be in the GROUP BY. The query I wanted to write is: SELECT * FROM Words GROUP BY Id, Lang HAVING Rev=Max(Rev) > Given that I have my Primary Key as (Id,

Re: [sqlite] Three LEFT JOIN issues

2008-07-03 Thread Csaba
On Tue, Jul 1, 2008 at 2:53 PM, Igor Tandetnik <[EMAIL PROTECTED]> wrote: > "Csaba" <[EMAIL PROTECTED]> wrote in > message news:[EMAIL PROTECTED] >> 1) In the following LEFT JOIN, is it possible to alter >> the query so that there is no w. prefix at the >> beginning of each returned column name:

Re: [sqlite] rollback/replay journals and durability of the mostrecent transaction

2008-07-03 Thread D. Richard Hipp
On Jul 2, 2008, at 11:07 PM, Ken wrote: > > So if I insert large amounts of data, this data would be written to > disk > twice: once into a replay journal, and then again into the database > file > on commit. With rollback journal, it is written once into the database > (with rollback journal

Re: [sqlite] validate SQL Statement

2008-07-03 Thread D. Richard Hipp
On Jul 2, 2008, at 11:03 PM, Umaa Krishnan wrote: > I was wondering if there a way in sqlite, wherein I could validate > the SQL statement (for correct grammar, resource name - column name, > table name etc), w/o having to do prepare. You speak as if sqlite3_prepare() were a huge burden -

Re: [sqlite] PRAGMA synchronous = OFF on transaction-safe file system TFAT WinCE

2008-07-03 Thread [EMAIL PROTECTED]
Hi! We have a 14MB SQLite database on a 16MB flash disk. The journal file gets to big on some queries, which results in a SQLITE_FULL error. Any other ideas to make data storage secure? Regards Daniel ___ sqlite-users mailing list