Re: [sqlite] Parsing create statements

2010-01-20 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 BareFeet wrote: > At the moment I am resorting to developing regular expressions to do the > parsing. They work, but it seems to be re-inventing the wheel. You won't be able to do parsing completely with regular expressions. Create statements let

Re: [sqlite] fastest way to get the min/max

2010-01-20 Thread Dan Kennedy
On Jan 21, 2010, at 1:54 AM, Pavel Ivanov wrote: >> Why the difference in search time between searching individually and >> searching together? > > Apparently SQLite is not smart enough to optimize the search for both > min and max to make double entrance to the index - first from the >

Re: [sqlite] Parsing create statements

2010-01-20 Thread BareFeet
Hi All, Following up my own post: > Is there any way to parse a create statement (eg create table, create view, > create trigger) into its components? At the moment I am resorting to developing regular expressions to do the parsing. They work, but it seems to be re-inventing the wheel. For

Re: [sqlite] Parsing create statements

2010-01-20 Thread BareFeet
Hi Stephan, > Does this help? > > pragma table_info([table-name]) > > The output looks easier to parse than the create-table statement. Thanks for the link. Yes, I am aware of the pragma table_info command. I use it to generate each column's name and type, but it doesn't give table

Re: [sqlite] Parsing create statements

2010-01-20 Thread BareFeet
Hi Simon, >> Is there any way to parse a create statement (eg create table, create view, >> create trigger) into its components? > Have you seen > > > > ? You can do this with many kinds of statements, not just SELECT. It > doesn't do just what you

Re: [sqlite] fastest way to get the min/max

2010-01-20 Thread Robert Citek
On Wed, Jan 20, 2010 at 1:54 PM, Pavel Ivanov wrote: >> Why the difference in search time between searching individually and >> searching together? > > Apparently SQLite is not smart enough to optimize the search for both > min and max to make double entrance to the index -

Re: [sqlite] fastest way to get the min/max

2010-01-20 Thread Pavel Ivanov
> Why the difference in search time between searching individually and > searching together? Apparently SQLite is not smart enough to optimize the search for both min and max to make double entrance to the index - first from the beginning, then from the end. It does search through the full index

Re: [sqlite] fastest way to get the min/max

2010-01-20 Thread Robert Citek
On Wed, Jan 20, 2010 at 8:52 AM, Max Vlasov wrote: > I thought at the first moment that Pavel's suggestion on using extra index > is very "expensive" in terms of megabytes on the disk, but despite this > drawback it's actually more robust. For my own curiosity I created a

Re: [sqlite] Parsing create statements

2010-01-20 Thread Stephan Wehner
On Wed, Jan 20, 2010 at 6:13 AM, BareFeet wrote: > Hi All, > > This question seems to come up every now and then, but I've yet to see any > solution. The best phrasing of the question I found was back in 2004: >

Re: [sqlite] Parsing create statements

2010-01-20 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 BareFeet wrote: > Is there any way to parse a create statement (eg create table, create view, > create trigger) into its components? One simple way is to use an authoriser while calling sqlite3_prepare. You'll find every action that is done by the

Re: [sqlite] Attached database

2010-01-20 Thread Pavel Ivanov
> Is it possible? If I attach database B to database A and database A to > database B. As these statements are committed into A and B, they stay > attached even if I close and reopen. So If another process opens A (or B), > it has B (or A) attached to A (or B). I don't have to repeat the ATTACH >

Re: [sqlite] Attached database

2010-01-20 Thread Tiberio, Sylvain
Hi, > And how precisely do you expect SQLite to pull that off? Ignore the DETACH command and set and error... No? As when you insert a row that doesn't respect a constraints. > How it is going to stop you from, say, opening a separate > connection to one of these databases (and never attaching >

Re: [sqlite] fastest way to get the min/max

2010-01-20 Thread Robert Citek
On Wed, Jan 20, 2010 at 8:52 AM, Max Vlasov wrote: >> One of many ways would be to precompute the min/max into a separate >> table and then query that table whenever you need the min/max. > > I thought at the first moment that Pavel's suggestion on using extra index > is

Re: [sqlite] Attached database

2010-01-20 Thread Tiberio, Sylvain
Ok, thanks! Sylvain -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Pavel Ivanov Sent: Wednesday, January 20, 2010 5:16 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Attached database > Ok, so

Re: [sqlite] Attached database

2010-01-20 Thread Igor Tandetnik
Tiberio, Sylvain wrote: > About "cross-database foreign key constraints": I agree with you that > attached database can be dettached or changed. So as it is not > possible to > create the foreign key constraint with no attached database (because > parent > table

Re: [sqlite] Attached database

2010-01-20 Thread Pavel Ivanov
> Ok, so cross-database view is not supported. Right? Correct. I remember there was some message on this list about these matters. And IIRC it even offered some simple patch to SQLite sources to allow cross-database view support. You might try to search the archives. > So as it is not possible

Re: [sqlite] Attached database

2010-01-20 Thread Tiberio, Sylvain
Ok, so cross-database view is not supported. Right? About "cross-database foreign key constraints": I agree with you that attached database can be dettached or changed. So as it is not possible to create the foreign key constraint with no attached database (because parent table doesn't exist), I

Re: [sqlite] Attached database

2010-01-20 Thread Pavel Ivanov
I wouldn't say anything about views - from my POV there's no much harm in supporting cross-database views other than possible user confusion (personally I don't know why it was decided to not support this). But concerning foreign keys: how do you think SQLite is supposed to enforce foreign key

[sqlite] Attached database

2010-01-20 Thread Tiberio, Sylvain
Hi, I remark some effects if I use a main database with other attached database (ATTACH command): - I cannot create view in main database that select columns from main database and attached database. - There is no foreign key constraints control is the foreign key is on an attached database table.

Re: [sqlite] Parsing create statements

2010-01-20 Thread Simon Slavin
On 20 Jan 2010, at 2:13pm, BareFeet wrote: > This question seems to come up every now and then, but I've yet to see any > solution. The best phrasing of the question I found was back in 2004: > http://www.mail-archive.com/sqlite-users@sqlite.org/msg02649.html > > Is there any way to parse a

[sqlite] Parsing create statements

2010-01-20 Thread BareFeet
Hi All, This question seems to come up every now and then, but I've yet to see any solution. The best phrasing of the question I found was back in 2004: http://www.mail-archive.com/sqlite-users@sqlite.org/msg02649.html Is there any way to parse a create statement (eg create table, create view,

Re: [sqlite] fastest way to get the min/max

2010-01-20 Thread Max Vlasov
> > > > One of many ways would be to precompute the min/max into a separate > table and then query that table whenever you need the min/max. > Only if one have full control about how the data changes what with so widespread format as sqlite almost always not the case. I mean without triggers you

Re: [sqlite] fastest way to get the min/max

2010-01-20 Thread Robert Citek
> On Wed, Jan 20, 2010 at 6:24 PM, hi wrote: >> For my application I am storing about "1770" rows into sqlite table, >> and when taking 'min' or 'max' it takes about ~7 to 10 seconds. >> >> Can you please suggest effective ways to get min/max values. How are you

Re: [sqlite] fasted way to get the min/max

2010-01-20 Thread Pavel Ivanov
Create an index on the field which you're getting min/max of. Then getting min/max will take some milliseconds. Pavel On Wed, Jan 20, 2010 at 7:54 AM, hi wrote: > Hi, > > For my application I am storing about "1770" rows into sqlite table, and > when taking 'min'

Re: [sqlite] fastest way to get the min/max

2010-01-20 Thread hi
Sorry for the wrong subject: On Wed, Jan 20, 2010 at 6:24 PM, hi wrote: > Hi, > > For my application I am storing about "1770" rows into sqlite table, > and when taking 'min' or 'max' it takes about ~7 to 10 seconds. > > Can you please suggest effective ways to get

[sqlite] fasted way to get the min/max

2010-01-20 Thread hi
Hi, For my application I am storing about "1770" rows into sqlite table, and when taking 'min' or 'max' it takes about ~7 to 10 seconds. Can you please suggest effective ways to get min/max values. Thank you in advance. -Hiral ___ sqlite-users

Re: [sqlite] ascii separator character in .import

2010-01-20 Thread Simon Slavin
On 20 Jan 2010, at 3:42am, RevBayes wrote: > I was trying to use the .import tool in sqlite. I was wondering if there was > a way to specify any arbitrary ascii character via the .separator command. > > e.g. if i want to use 0x05 (some non-printable ascii char) as the separator, > how do i