Re: [sqlite] Parsing create statements

2010-01-21 Thread BareFeet
Hi Richard, Thanks for your reply: > SQLite doesn't really do a parse tree so much. It does a little. Sometimes. > But its style of operation is closer to "syntax directed translation", > especially for the CREATE TABLE statement. So is there any way to extract a meaningful breakup of a

Re: [sqlite] Parsing create statements

2010-01-21 Thread BareFeet
Hi Roger, > 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 you specify default values

Re: [sqlite] Parsing create statements

2010-01-21 Thread D. Richard Hipp
On Jan 21, 2010, at 5:36 PM, BareFeet wrote: > > Vivien wrote: >> You can use SQLite's own SQL parser >> (http://www.hwaci.com/sw/lemon/lemon.html) with SQLite's own grammar >> (to ba found in SQLite's sources) and adapt it to you needs. > > That's the theory, but how can I do that easily? It

Re: [sqlite] Parsing create statements

2010-01-21 Thread BareFeet
Hi Vivien, >> BareFeet wrote: >> >> Is there any way to parse a create statement (eg create table, create view, >> create trigger) into its components? >> >> Since SQLite does this internally using the Lemon parser, surely there's a >> simple way to get the parser results? Vivien wrote: >

Re: [sqlite] Parsing create statements

2010-01-21 Thread Vivien Malerba
> 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 you specify default values for a column

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] 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] 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] 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,