Re: [sqlite] Query with UNION on large table

2011-06-24 Thread Jean-Christophe Deschamps
Rense, As for the ranges of n1 and n1: they are both roughly between 6 and 1200 . Here are the results of EXPLAIN QUERY PLAN SELECT n1, n2 FROM table1 Where n1 n2 INTERSECT SELECT n2, n1 FROM table1 Where n2 n1; 1|0|0|SCAN TABLE table1 (~437976176 rows) 2|0|0|SCAN TABLE table1

Re: [sqlite] Query with UNION on large table

2011-06-24 Thread Jean-Christophe Deschamps
Hi Rense, Thanks for this idea. In fact, the purpose of my original query is exactly to reduce the database. The 800 mln rows were exported from another source, and I was hoping to be able to use sqlite to manage this massive amount of data (e.g., removing redundant information) before I proceed

Re: [sqlite] unexpected effect of view nesting on type conversion

2011-06-22 Thread Jean-Christophe Deschamps
I've run into a phenomenon I don't understand where view nesting affects types. Give me a try: Form what I understand, views don't have their own types, so default affinity applies. 12.0 gets converted to 12 as an integer in v2 when the value gets picked from v1. Please someone correct me

Re: [sqlite] Is there a difference between DELETE and UPDATE/INSERT in terms of syncing to disk?

2011-06-15 Thread Jean-Christophe Deschamps
Kevin, I have confirmed that the DELETE does indeed delete the record, but only after Django's delete callback has completed. If what you say is true, that DELETEs are proceed immediately, then the only other explanation is that Django, upon sending of the post_delete signal, has not actually

Re: [sqlite] Implementing busy-waiting on SQLite

2011-06-13 Thread Jean-Christophe Deschamps
As was being discussed yesterday, I have four processes accessing the same database file. When they perform an sqlite action, I wish them to block if the DB is not available. SQLite does not block if it finds the db busy or locked, it returns an error code. You can have SQLite do all this by

Re: [sqlite] Implementing busy-waiting on SQLite

2011-06-13 Thread Jean-Christophe Deschamps
Hi Jay, Invoke sqlite3_busy_timeout() with a safe timeout for every connection to the DB. Use IMMEDIATE transactions everywhere. That's all you have to do. Well, yes and no. You still have to deal with the case of SQLITE_BUSY being returned due to deadlocks. Setting a timeout

Re: [sqlite] sqlitebrowser - anyone compiled a recent one?

2011-06-09 Thread Jean-Christophe Deschamps
Thanks. I was prepared to receive alternate suggestions :) I wanted to have hands on and control over a browser with which can follow sqlite versions quicker. Sqlitebrowsers tend to lag behind the Sqlite development. Then give SQLite Expert a try! http://www.sqliteexpert.com/

Re: [sqlite] Handling of IEEE-754 nan and +/-inf in SQLite?

2011-06-07 Thread Jean-Christophe Deschamps
Sure, if you're just computing average() then you'll not get any NaNs. NaNs, NO (if we don't have NaNs in the set) but issues, YES. It all depends. No one knows. You don't even know what you're computing exactly. SQL interpret avg() as take this data as a set, sum up these numerical values

Re: [sqlite] Proper way to escape table name and column name

2011-06-06 Thread Jean-Christophe Deschamps
What is the official way to escape table name that contains a space and column name that contain a spaces? You can use square brakets or double-quotes: [This is a long name for a small table] This is a long name for a small table as well ___

Re: [sqlite] Handling of IEEE-754 nan and +/-inf in SQLite?

2011-06-06 Thread Jean-Christophe Deschamps
Allow me to add a humble bit to what Jay just posted. SQLite, as well as most other RDBMS around, allow you to perform FP calculations in SQL statements. I assume no-one imagines an extended FP fine-grain support of hundreds of computation options and status reporting be part of SQL or

Re: [sqlite] Handling of IEEE-754 nan and +/-inf in SQLite?

2011-06-06 Thread Jean-Christophe Deschamps
Nico, There is one thing that makes numerical support in RDBMSes important: aggregate functions. Aggregate functions are critical because they allow one to do much analysis at the data source, instead of having to transport it elsewhere for analysis. I agree with you, totally. Read me again: I

Re: [sqlite] What is so slow on dropping tables?

2011-06-01 Thread Jean-Christophe Deschamps
Quoth Roger Binns rog...@rogerbinns.com, on 2011-06-01 00:21:44 -0700: On 05/31/2011 12:18 PM, Jan Hudec wrote: - Is there any way to speed it up? Another way (somewhat hinted at by Nico) is that you can create these tables in separate databases and use attach to bring them in. To

Re: [sqlite] Unlocking the database

2011-05-28 Thread Jean-Christophe Deschamps
I understand the need for integrity when locking a database, but in this case I knew that the problem was caused by a (in all honesty, my) bug. I tried rebooting the machine and it did not unlock the table. Yeah, sometimes Windows will keep a lock on a file beyond reboot, which is something

Re: [sqlite] Is it possible to optimize the read performanceof a C++ app using sqlite pragma journal_mode = wal pragmawal_checkpoint?

2011-05-26 Thread Jean-Christophe Deschamps
Simon Slavin, Thank you for your suggestion. Our deduper prototoype uses fuzzy matching methods such as the Levenshtein Distance to detect duplicates. We have found that these fuzzy matching methods are best implemented in C++ for processing time requirements. We would

Re: [sqlite] [BUG] Silent change in intergeral overflow handling in 3.7.6

2011-05-25 Thread Jean-Christophe Deschamps
Richard, At 13:07 25/05/2011, you wrote: It turns out that the expected behavior does not happen in modern C compilers. Overflow of signed integers is undefined behavior in C. So if you have a signed integer overflow, it might wrap the result (the expected result) or it might segfault, or it

Re: [sqlite] Possibly Alias Bug

2011-05-23 Thread Jean-Christophe Deschamps
I have problems with column aliasing using AS when I select rows with the same string: .headers ON CREATE TABLE TEST1 (name TEXT,value TEXT); INSERT INTO TEST1 VALUES (name1,value1); SELECT value AS name1 FROM TEST1 WHERE name=name1; // gives no result SELECT value AS name1_ FROM TEST1 WHERE

Re: [sqlite] date field with default current date

2011-05-23 Thread Jean-Christophe Deschamps
I resolved with: CREATE TRIGGER insert_nameTable after insert on name_tabl begin update set ww = datetime('now','localtime') where rowid = new.rowid; end You don't have to fire a trigger for such default: CREATE TABLE test ( mydate CHAR DEFAULT

Re: [sqlite] (no subject)

2011-05-20 Thread Jean-Christophe Deschamps
Ah, there is a way to write it so that you can have at most one of those constraints where only one makes sense, and not require a specific order of constraints, but it'd require listing all the possible orderings, which would be impractical. So if one wanted to enforce that there's at most one

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-19 Thread Jean-Christophe Deschamps
On Wed, May 18, 2011 at 4:10 PM, Petite Abeille petite.abei...@gmail.com wrote: On May 18, 2011, at 10:50 PM, Danilo Cicerone wrote: How can I simulate a calendar table(maybe using the strftime funtion)? Well, you have two broad options: (1) materialize the calendar as a table (2)

Re: [sqlite] SQL Statement Help(selecting days).

2011-05-19 Thread Jean-Christophe Deschamps
Since we use recursive triggers, set recursive_triggers pragma beforehand if not yet done. Cunning. A bit of a Rube Goldberg apparatus though, no? Huh? Still way more flexible than having to modify C source of a vtable module, should you have to adapt anything. Yeah, it's kind of

[sqlite] Usefulness of FKs to multiple tables

2011-05-19 Thread Jean-Christophe Deschamps
Let me ask this by mere curiosity. SQLite will accept and process the following: CREATE TABLE x (a CHAR PRIMARY KEY); CREATE TABLE y (a CHAR PRIMARY KEY); CREATE TABLE z (a CHAR REFERENCES x(a) REFERENCES y(a)); I didn't check if the last FK is even valid normative SQL and that isn't the heart

[sqlite] (no subject)

2011-05-19 Thread Jean-Christophe Deschamps
Anoher (silly) question about what SQLite considers valid input, again out of mere curiosity. A statement like: CREATE TABLE a (a CHAR COLLATE NOCASE COLLATE BINARY, b INTEGER DEFAULT 1 DEFAULT 2); doesn't cause any error: SQLite applies only the last constraint of each type, namely COLLATE

[sqlite] Caveat in parsing create table statement

2011-05-13 Thread Jean-Christophe Deschamps
Dear list, Is there a way to make SQLite accept this kind of constraint: CREATE TABLE tab ( id INTEGER NOT NULL, data INTEGER, CHECK(data = 0 or not exists (select 1 from tab where id = data))); This toy exemple doesn't mean much as it is and the actual situation is a bit more

Re: [sqlite] SQLITE return codes for insert/delete/update/select

2011-05-11 Thread Jean-Christophe Deschamps
I agree with what you stated but it would have been more clearer if the result of the update statement was a RECORD NOT FOUND return value since it did not find any that met the query's criteria. How can you say that the UPDATE was successful when the record you were looking for does not even

Re: [sqlite] SQLite as a Logger: How to mimic rotation of logs?

2011-05-10 Thread Jean-Christophe Deschamps
Without a view (but with a trigger) and certainly open to improvement (9 is the MAX_ENTRIES parameter): CREATE TABLE log ( id INTEGER NOT NULL PRIMARY KEY ON CONFLICT REPLACE AUTOINCREMENT, seq INTEGER CONSTRAINT ix1Seq UNIQUE ON CONFLICT REPLACE, data CHAR); CREATE TRIGGER trInsLog

Re: [sqlite] Issue 608 in sqlite-manager: select date('2011-04-29', quote(-3) || 'day'); shows null after upgrading of firefox to 3.6.17

2011-05-08 Thread Jean-Christophe Deschamps
Change that into: select date('2011-04-29', quote(-3) || ' day'); (note the space before day). Looks like a parsing change. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] Determining how many columns were returned in a query

2011-05-08 Thread Jean-Christophe Deschamps
How does one go about finding out how many rows a query returns? This is the number of time sqlite3_step can be called successfully until it returns SQLITE_DONE. Is there a way to find out the id of a particular column? AFAICT column don't have ids. You can read column names or alias using

Re: [sqlite] Determining how many columns were returned in a query

2011-05-08 Thread Jean-Christophe Deschamps
How about: SELECT count() FROM (original query’s SELECT statement); You can do that (and variations) but this is a completely distinct statement. I meant that there is no possibility to recover the row count of a result set before it goes to completion (by iterating step), just because

Re: [sqlite] Determining how many columns were returned in a query

2011-05-08 Thread Jean-Christophe Deschamps
I happen to have a code path such that the select statement can return 1, 3 or 5 columns. I know I could go based on count, but if I could do it by name that would be safer. I had not considered the point that multiple columns could have the same name, though, so I fully understand why such a

Re: [sqlite] Feature request: Fuzzy searching

2011-05-04 Thread Jean-Christophe Deschamps
I apologize if double-post, the first one didn't make it to the list. - Hi, Hi all, I am interested in seeing fuzzy searching in SQLite, for lack of a better term. This type of search would return more results than LIKE

Re: [sqlite] How to Use an Apostrophe in a Text Field?

2011-04-21 Thread Jean-Christophe Deschamps
The apostrophes are escaped by apostrophes. Correct. http://www.sqlite.org/faq.html#q14 One more way you can do. insert into table name (column name) values (*Goin' Down the Road Feelin' Bad*); It is double quotes before and after *. Similarly double quotes will be escaped by one more

Re: [sqlite] How to Use an Apostrophe in a Text Field?

2011-04-21 Thread Jean-Christophe Deschamps
True. I will get rid of the habit of using double quotes for string literals. Thanks for information. But most of the databases support this non standard behavior. Yeah ... until things break under your feet due to a new version not sticking to the non-standard behavior anymore or parser

Re: [sqlite] insert help

2011-04-19 Thread Jean-Christophe Deschamps
Newbie here. i'm trying to insert multiple values into a table by a certain date and when I use where clause it fails. This is my code insert into db (table) values ('value') where date = 'date range'. Thanks for any help. There is no where clause in insert statements, it wouldn't make

Re: [sqlite] insert help

2011-04-19 Thread Jean-Christophe Deschamps
My date column is set when the program starts and i do not want it to change. How is this date column set in the database without inserting anything? So I have my dbname with mytable and two columns date and value column. I have say 5 values (1 2 3 4 5) that I wanted inserted into mytable

Re: [sqlite] Trouble inserting null value from txt file

2011-04-08 Thread Jean-Christophe Deschamps
It's impossible when you use standard sqlite3 command line utility. In your particular case you have 2 options: either write your own application that will recognize some kind of value as null and insert it instead of plain text, or you can use temporary table like this: Another way is to use

Re: [sqlite] read full txt file in one record

2011-04-06 Thread Jean-Christophe Deschamps
3. edit the database file with a hex editor, replacing ~~ with 0D 0A. That seems pretty dangerous! Rather update the table using the standard replace() function. ___ sqlite-users mailing list sqlite-users@sqlite.org

Re: [sqlite] sqlite bug? -- inconsistent time searches

2011-04-02 Thread Jean-Christophe Deschamps
It's a pain in the arse that one has to pay for copies of the ISOs. What do they think we're paying them for ? I also find this a perverse effect totally contrary to their mission or at least its spirit: produce good standards for public use. Without free access to reference up-to-date

Re: [sqlite] Lack of decimal support

2011-03-27 Thread Jean-Christophe Deschamps
There are many cases where people are doing calculations or using numbers expecting them to retain all digits. This would allow the BCD type to be used for that if they really need it. Currency conversions (rarely exact!) or tax (or margin) calculations come to mind as very common uses

Re: [sqlite] Lack of decimal support

2011-03-27 Thread Jean-Christophe Deschamps
This page has a lot of info about Decimal Number support, including a set of libraries: http://speleotrove.com/decimal/ Yes! IBM and Intel are two of the big names having done significant work in this direction and made research and/or results publicly available.

Re: [sqlite] Sorting of Korean Language Characters

2011-03-23 Thread Jean-Christophe Deschamps
At 09:43 23/03/2011, you wrote: I am working on one application which require sorting for Korean Language. The Korean Characters sort by Jamo(Hangul Jamo) ie based on KSX1001 character code. Does sqlite3 or any other package support this type of sorting ? If not , then any clue to carry out

Re: [sqlite] storing big numbers into NUMERIC, DECIMAL columns

2011-03-23 Thread Jean-Christophe Deschamps
At 18:46 23/03/2011, you wrote: Current US national debt is 16 digits. Nothing less? That's where the bug lies. OK, OK, I'm out ;-) ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

[sqlite] Passing key as string in system.data.sqlite

2011-03-04 Thread Jean-Christophe Deschamps
Hi Dear list, I'm looking into system.data.sqlite and I've been asking myself questions about the most portable encoding of a text passphrase to sqlite_[re]key. It seems to me that the only portable way is to pass an UTF-8 string since it's the only encoding invariant wrt byte order and

Re: [sqlite] UPDATE/INSERTing 1-2k rows slower than expected

2011-02-13 Thread Jean-Christophe Deschamps
So if the drive is 5400 rpm, 227 is much more than 5400/60=90 and even if it's 7200 (manufacturers sometimes upgrade drives inside portable hd without prior notice), it's still twice as much as 7200/60=120. 5400/60, 7200/60 ... those values rely on the assumption that successive LBAs are

Re: [sqlite] UPDATE/INSERTing 1-2k rows slower than expected

2011-02-13 Thread Jean-Christophe Deschamps
But what I postulate is that you can't physically write *the same* record over and over more than 90 times per second on a 5400 rpm drive, unless the drive, OS, or filesystem implements something like wear-leveling, where the physical location of sectors is constantly changing. It's still

Re: [sqlite] SQLite version 3.7.6 testing

2011-02-12 Thread Jean-Christophe Deschamps
Your goals make a lot of sense. However I think you can do my second suggestion. Compile with STAT2 code included by default, but make the analyze command only build stat1 by default. This will result in no change in default behaviour, but means that anyone wanting to use stat2 can easily do

Re: [sqlite] Trigger to filter out characters

2011-02-07 Thread Jean-Christophe Deschamps
Could you please show me how to write the condition (to filter out characters)? Use the strfilter function found in extension-functions.c downloadable from http://www.sqlite.org/contrib/ Once built and loaded, you can use a trigger similar to create trigger if not exists trFilterAB after

Re: [sqlite] slow select from table with data blob

2011-01-30 Thread Jean-Christophe Deschamps
It seemed strange that a simple select * from table that I was doing was so slow. The table contained about 20 columns (fields) and 300 rows. The select took about 1.5 seconds. (using SQLite Expert). Does the run time settle at 1.5 s after a few runs or is that a first-run time ? As an aside

Re: [sqlite] REGEXP parameter order

2011-01-24 Thread Jean-Christophe Deschamps
Sorry for elementary questions but when implementing a REGEXP function (I'm using PCRE from pcre.org) I need to know in which order the two arguments (target, pattern) will be passed to the function. I also would like to retain the last pattern used in compiled form (connection-wise).

Re: [sqlite] REGEXP parameter order

2011-01-24 Thread Jean-Christophe Deschamps
Hi Igor, I'm not quite sure what you are talking about, but see the documentation of like() and glob() functions here: You're right about LIKE and GLOB. ___ sqlite-users mailing list sqlite-users@sqlite.org

[sqlite] REGEXP parameter order

2011-01-23 Thread Jean-Christophe Deschamps
Hi all, Sorry for elementary questions but when implementing a REGEXP function (I'm using PCRE from pcre.org) I need to know in which order the two arguments (target, pattern) will be passed to the function. I also would like to retain the last pattern used in compiled form (connection-wise).

Re: [sqlite] how to put the database in cache without waiting the system do it by himself ?

2011-01-13 Thread Jean-Christophe Deschamps
when i just launch th application, at the beginning the query can take around fews seconds... but after some time (10 - 20 minutes), it's take only few ms ! so i guess it's because the windows cache in memory the database file ? so how to speed up this time to make windows cache more fastly in

Re: [sqlite] Propose minor incompatible API change

2011-01-11 Thread Jean-Christophe Deschamps
This is, technically, a compatibility break. On the other hand, there appear to be vast numbers of smartphone applications that currently depend on undefined behavior and will suddenly stop working if we don't make this change. I understand the proposed change will have no incidence for

Re: [sqlite] Propose minor incompatible API change

2011-01-11 Thread Jean-Christophe Deschamps
An end user (think: your mom) wants to upgrade her smartphone to the latest OS release. That new OS release includes the latest shared library for SQLite. But in so doing, some percentage of the apps she has downloaded cease to work. Sure, the problem really is that the apps were incorrectly

Re: [sqlite] fill blank fields

2011-01-09 Thread Jean-Christophe Deschamps
thanks Simon and Igor for your help on this a few weeks ago, but I need an addition to UPDATE Aircraft SET CN = '*' where CN = '' or CN is null; what I need to do is replace blank fields in a specific row, sort of a double where where statement as in: UPDATE Aircraft SET CN = '*' where CN =

Re: [sqlite] Rounding Strategy

2011-01-04 Thread Jean-Christophe Deschamps
select round(3.05, 1) 3.0 Is this expected behavior for SQLite? The documentation isn't specific on the rounding strategy that is used. My personal expectation was that this would round to 3.1. You _expect_ that 3.05 will represent exactly as 3.05 in IEEE, but it that the case? Should the

Re: [sqlite] Rounding Strategy

2011-01-04 Thread Jean-Christophe Deschamps
Scott, SQLite handles rounding by running the value through the internal printf with the appropriate precision. As best I can tell the internal printf adds half a unit at the appropriate position, then truncates. Yep, truncation is a way to do it but doesn't meet layman expectations in many

Re: [sqlite] delete from t1 where not in (null)

2010-12-24 Thread Jean-Christophe Deschamps
Hi, SQLite sounds pretty reasonnable to me: select select distinct favicon_id from moz_places; select distinct favicon_id from moz_places; Returns NULL select deleting: standard method...; delete from moz_favicons where id not in (select distinct favicon_id from moz_places); -- here is the

Re: [sqlite] SQL query on sort order

2010-12-16 Thread Jean-Christophe Deschamps
Harish, We have a problem with a sql query. In a table, a column called name contains character data that may include alpha, numeric and special characters. It is required to sort in such a way that names starting with alpha characters are listed first, then numerals and finally special

Re: [sqlite] cost of sqlite3_open

2010-11-30 Thread Jean-Christophe Deschamps
Pavel, 1) How expensive is a call to sqlite3_open. Does a call to sqlite3_enable_shared_cache make it cheaper? Its cost depends on the size of your schema as it gets parsed during open. Isn't this contradictory with an answer by Igor made in a recent thread? Subject: Re: [sqlite]

Re: [sqlite] cost of sqlite3_open

2010-11-30 Thread Jean-Christophe Deschamps
It's not contradictory. I say that real cost of sqlite3_open is parsing the schema. Igor says that this cost is actually deferred from inside sqlite3_open call to the first substantive sqlite3_step call. So you will have to pay this price anyway, just profiler output would be somewhat confusing.

Re: [sqlite] SQLITE 3.7.3 bug report (shell) - output in column mode does not align UTF8-strings correctly

2010-11-26 Thread Jean-Christophe Deschamps
At 14:26 26/11/2010, you wrote: N.b., there is a severe bug (pointers calculated based on truncated 16-bit values above plane-0) in a popular Unicode-properties SQLite extension. The extension only attempts covering a few high-plane characters—if memory serves, three of thhem in array 198; but

Re: [sqlite] Reducing time to create indexes

2010-11-24 Thread Jean-Christophe Deschamps
Simon, I'll try that and see what difference itmakes That or build a :memory: DB, populate it, build indices and then only back it up to disk using the backup API. That requires you have enough memory available, but should be really fast if you have.

Re: [sqlite] Confused by import of NULL values from CSV file

2010-11-22 Thread Jean-Christophe Deschamps
I import a CSV flat file into a table (using sqliteman as GUI). The flat file has NULL values as simply no data between two delimiters (I use 'tab' as Delimiter). The resulting table does not treat 'no data' between 2 delimiters as NULL. When I run CHECK constraints etc. on it it behaves as

Re: [sqlite] SQLITE: sorting

2010-10-12 Thread Jean-Christophe Deschamps
Look in your mailbox. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] pragma foreign_keys not persistent?

2010-09-14 Thread Jean-Christophe Deschamps
As far as I can tell, turning on foreign_keys for a database is not persistent. It only seems to be valid for that connection/session. So this means I have to prefix every command that I send to the database with a command to turn on foreign_keys and I therefore can't issue one-off commands,

Re: [sqlite] PRAGMA database_list: insert into table?

2010-07-26 Thread Jean-Christophe Deschamps
But Roger, the layer sitting in front of SQLite is a programming environment which provides its own (black-box) connectivity to SQLite, and it isn't going to be calling any DLL into which one will have injected a UDF library in the manner you have laid out, and it's not going to let the

[sqlite] ON conditions vs. WHERE conditions

2010-07-20 Thread Jean-Christophe Deschamps
What is the rationale about placing complex conditions in the ON part of an inner join rather than in an WHERE clause? I understand that the ON clause will limit the temporary table processed by a subsequent WHERE clause, while a larger table will be filtered by the WHERE part if no selective

Re: [sqlite] ON conditions vs. WHERE conditions

2010-07-20 Thread Jean-Christophe Deschamps
What is the rationale about placing complex conditions in the ON part of an inner join rather than in an WHERE clause? Except for outer joins, the difference is purely stylistic. They are functionally equivalent. In fact, SQLite internally rewrites the former to the latter, before

Re: [sqlite] error in sum function

2010-07-14 Thread Jean-Christophe Deschamps
allow. -- Jean-Christophe Deschamps eMail: mailto:j...@q-e-d.orgj...@q-e-d.org SnailsTo: 1308, route du Vicot 40230 Saint Jean de Marsacq France GSM: +33 (0)6 15 10 19 29 Home:+33 (0)5 58 77 71 79

Re: [sqlite] Reg: In Memory Database Using SQLite

2010-07-06 Thread Jean-Christophe Deschamps
I'm aware that SQLite offers the functionality of in-memory databases, but I don't know how to read the data and send it over the wire to the server or how to push the data into the in-memory database of the server. The backup API included in SQLite offers the facility to backup/restore (in

Re: [sqlite] CREATE TABLE work arounds?

2010-06-10 Thread Jean-Christophe Deschamps
I am parsing fields on the fly and then creating tables, unfortunately one of the fields is Order and is a special word in SQL as is not allowed. Is there a way around this instead of intercepting with perl s'/Order/Orders/g' Can you wrap every column name inside double quotes or square

Re: [sqlite] copy data from one db to another

2010-06-08 Thread Jean-Christophe Deschamps
What's the best way to copy data from one db to another? Given 2 databases with identical schemas, one full of data and the other empty, the brute force way would be to perform selects on the source db, then for each row, perform an insert into the destination db. Is there a more efficient way?

Re: [sqlite] how to search for asterix character?

2010-05-26 Thread Jean-Christophe Deschamps
How do I search for the asterix character * ?? This doesn't work: select field1 from table1 where field1 like '%FH%*%' as the * character here seems to be ignored. Using the latest version of SQLite. You're doing it right. Either you use a wrapper that messes with * in litterals or there is

Re: [sqlite] how to search for asterix character?

2010-05-26 Thread Jean-Christophe Deschamps
I use vb or in SQLlite Expert the * does not seem to work From my testing * doesn't seem to work in the likeif I use '%33' it returns everything with test33if I use '33%' it returns everything with 33testif I use '%33%' it returns everything with 33test, test33 which is the same as * I can't

Re: [sqlite] network access problem

2010-05-24 Thread Jean-Christophe Deschamps
Running in sqlite application in Virtual Box, attempt to open a database with sqlite from a shared network folder \\Vboxsvr\testdata however the open16 and openv2 (with read only) both fail --- rc = 14. File opens file if moved locally to hard drive. using latest version of sqlite3

Re: [sqlite] what languages

2010-05-21 Thread Jean-Christophe Deschamps
I use sqlite from within Autoit V3 (Autoit is a windows-oriented basic-like language) AutoIt, while a scripting language can be seen and used as a RAD platform. It enjoys good support, up to date SQLite embedding and executables produced can include any file your application needs, like a

Re: [sqlite] Loading Sqlite3 DB into memory

2010-05-20 Thread Jean-Christophe Deschamps
Is there any way to load a sqlite3 db from a location in memory? Ideally, I'd like to have a memory pointer (eg, something provided via malloc), which I could then use as the handle sqlite3 uses to load the database. The reason I'm trying to do this: I have an encrypted database file that I

Re: [sqlite] recursive select in sqlite

2010-05-17 Thread Jean-Christophe Deschamps
z i wonder is there RECURSIVE select function in sqlite? the background z for the question are: create table objects (id INTEGER PRIMARY KEY z AUTOINCREMENT, name text unique) create table tree(id int, child_id z int, PRIMARY KEY(id, child_id)) i want to draw the whole tree, is there z good

Re: [sqlite] multi processes, so many errores of SQLITE_BUSY and SQLITE_MISUSE

2010-05-13 Thread Jean-Christophe Deschamps
Let me take a reality check for the case of my own usage. If I guarantee that the following conditions are all true: All R^n (Read-Read-...-Read) atomic operations are enclosed in BEGIN transactions. All W^n (Write-Write-...-Write) and RMW (Read-Modify-Write) atomic operations are enclosed

Re: [sqlite] multi processes, so many errores of SQLITE_BUSY and SQLITE_MISUSE

2010-05-13 Thread Jean-Christophe Deschamps
In my low-concurrency, familly-business context, I have no problem at all setting 3 hours timeout using the built-in function, when the slowest transaction may only take less than 5 minutes. With this condition as a 4th one in your list and with 5th one stating that you have less than 30

Re: [sqlite] select intersecting intervals

2010-05-13 Thread Jean-Christophe Deschamps
The Minimal-Perfect-Hash-INTERSECTION-OF-VECTORS approach might benefit queries against tables having several million rows. What I'm wondering (and lack the C skills to find out for myself) is whether SQLite's underlying algorithms for INTERSECT could be optimized with a minimal perfect hash

Re: [sqlite] select intersecting intervals

2010-05-12 Thread Jean-Christophe Deschamps
I would first create an INTEGER primary key and then place an index on name, another on i_from, and another on i_to, and then see if the approach below has any benefit. When I tried this with a geo-queryit was actually slower than the standard select, and I'm curious if that's always going to

Re: [sqlite] SELECT question (computing day of week the using strftime() function)

2010-05-01 Thread Jean-Christophe Deschamps
I need to find out how many specific weekdays (e.g., how many Sundays) I have in any given range of dates. My problem: How to use the COUNT function in combination with the strftime() function. $ sqlite3 test.db3 SQLite version 3.6.20 sqlite create table test (date VARCHAR(20), money INTEGER);

Re: [sqlite] Searching with like for a specific start letter

2010-04-28 Thread Jean-Christophe Deschamps
Tim, But did I say that GLOB uses an index if it has been overloaded? No. I wrote that if LIKE has been overloaded, queries that contain LIKE won't use the index. Typically, GLOB won't have been overridden too just because LIKE has been overridden: the rationale for overriding the LIKE

[sqlite] Exclusive transactions over network

2010-04-27 Thread Jean-Christophe Deschamps
Hi gurus, I'm aware of the limitations that generally preclude using SQLite over a network. Anyway do you think that doing so with every read or write operation wrapped inside an explicit exclusive transaction can be a safe way to run a DB for a group of 10 people under low load (typically 2Kb

Re: [sqlite] Searching with like for a specific start letter

2010-04-26 Thread Jean-Christophe Deschamps
At 14:31 26/04/2010, you wrote: If the implementation of SQLite you are using overrides the LIKE operator (as more than a few do), then SQLite will not make use of an index on the column in question. Use the GLOB operator instead. I doubt it. GLOB is absolutely nothing more or less than an

Re: [sqlite] Searching with like for a specific start letter

2010-04-26 Thread Jean-Christophe Deschamps
Tim, Queries using GLOB do use the index on the column in question (i.e. optimization is attempted) Queries using LIKE do not use that index if the LIKE operator has been overridden. Sorry but GLOB doesn't use an index either if LIKE/GLOB has been overloaded. This is consistent with the docs

Re: [sqlite] Restriction of updating unique column

2010-04-18 Thread Jean-Christophe Deschamps
I found the the restriction of updating unique column in ver3.6.21. and same problem is reported in follwoing mail Marc-Andre Gosselin wrote: date: Thu, 16 Jun 2005 title: [sqlite] Update unique column I discovered a behavior in SQLite 2.8.16 that doesn't conform to the SQL standard,

Re: [sqlite] Restriction of updating unique column

2010-04-18 Thread Jean-Christophe Deschamps
Contrary to what occurs in other engines, SQLite seems to assert constraints at insert/delete time, ignoring the fact that (insert or delete) trigger will increment or decrement the upper part of the tree interval on HI and LO keys (in the case of a nested tree). This /should/ be handled

Re: [sqlite] SUBSTR overload and ALTER TABLE

2010-04-10 Thread Jean-Christophe Deschamps
We just experienced the hard way that overloading certain built-in SQL function can interfere with core SQL commands if the overloaded function behaves differently from the built-in function. Not surprising, after looking at the sources: * ALTER TABLE - alter.c uses SUBSTR and LIKE. * VACUUM

Re: [sqlite] Problem with sqlite providing different programs different data

2010-04-01 Thread Jean-Christophe Deschamps
Both of these tools show a version of the database that is different from what i see in the command line and they are equivalent in their discrepancies (they are different from the command line but the same as each other). So heres the basica scenario: 1. i update my database with the code i

Re: [sqlite] SQLite template files

2010-03-27 Thread Jean-Christophe Deschamps
Hi Tom, BTW- if you haven't done so already; it may be of use to the user to add extensions: VirtualText and Jean-Christophe Deschamps has an extension for fuzzy search for example. There is no problem. Alexey put it on his website under the extension for Unicode folder. Please drop me a mail

Re: [sqlite] All ancestors / descendents of a vertex in sqlite?

2010-03-18 Thread Jean-Christophe Deschamps
I have a (small) directed graph which I would be able to fins all ancestors or descendents of a certain vertex (transitive closure?). So, using this graph: CREATE TABLE levels_levels (parent_id INTEGER ,child_id INTEGER, UNIQUE(parent_id, child_id)); INSERT INTO levels_levels VALUES(6,7); INSERT

[sqlite] Result_* functions

2010-03-17 Thread Jean-Christophe Deschamps
Is it allowable/safe to invoke more than once any sqlite3_result_*() function? In other terms, subsequent invokation of any result function will it harmlessly override a previous one? As in: init... // once for all, post null return in anticipation for the various cases where // parameters

Re: [sqlite] Unicode command line bug in Windows version of sqlite3 with patch

2010-03-16 Thread Jean-Christophe Deschamps
We currently use sqlite 3.6.23. We have a big problem with characters with accents or other special characters in path to database file, for example in Czech Windows XP the Application Data folder is translated to Data aplikací so if the accented 'í' is in path the sqlite3.exe writes that it is

Re: [sqlite] regular expressions

2010-03-15 Thread Jean-Christophe Deschamps
is anybody aware of a possibility to do s.th. like select * from table where field like '[A|a]%' Unless non-standard compile option and provided you don't issue PRAGMA case_sensitive_like = 1; LIKE is case-insensitive, so LIKE 'A%' is the same as LIKE 'a%' SQLite offers another filtering

Re: [sqlite] if exist

2010-03-12 Thread Jean-Christophe Deschamps
Andrea Galeazzi wrote: I've got a table T made up of only two fields: INT id (PRIMARY KEY) and INT length. I need a statement in order to yield 0 when the key doesn't exist. Well, select 0; fits your spec (you never said what should be returned when the key does exist). I would hazard a

Re: [sqlite] if exist

2010-03-12 Thread Jean-Christophe Deschamps
Yours returns 1 or 0. Mine returns length if found, otherwise 0. That's true but the subject title led me to believe that the OP intended to have a 0 vs. nonzero return for not-exists vs exists condition. ___ sqlite-users mailing list

Re: [sqlite] Column types safe changes

2010-03-10 Thread Jean-Christophe Deschamps
And, of course, you'll have a table where some rows (old ones) contain integers and others (new ones) contain text. SQLite is fine with this, but your client software might not be prepared to deal with it. Some comparisons might behave in surprising ways. I imagine that in such case, the best

Re: [sqlite] Column types safe changes

2010-03-10 Thread Jean-Christophe Deschamps
Why not just update tbl set col1 = col1; or perhaps update tbl set col1 = cast(col1 as text); I'm not sure the former will actually change anything, but the latter should. Yes my untold question was merely if simpler col = col way could be simply ignored. You're right about the

<    1   2   3   4   >