iafisher / sqliteparser

A parser for SQLite's dialect of SQL
https://sqliteparser.readthedocs.io/en/latest/
MIT License
1 stars 1 forks source link

Parse functions #9

Closed luxint closed 2 years ago

luxint commented 2 years ago

Hi ,

this doesn't parse: create table t2 (c1 text, c2 text generated always as (upper(c1)));

also I noticed that you cannot omit the type, so

create table t1 (c1 text,c2 generated always as (2+2));

also doesn't parse.

btw looking at your isqlite interface, looks very nice!

iafisher commented 2 years ago

sqliteparser actually can't parse functions at all no matter where they appear. This shouldn't be hard to fix but I'm not sure when I'll have time to get around to it.

Just out of curiosity, are you using sqliteparser? Always interested to learn what people are doing with my libraries.

luxint commented 2 years ago

Hi,

I'm evaluating sqliteparser for an application on top of sqlite I'm developing. Reason is that I want to introspect sqlite db's and tables but sqlite doesn't provide al the information with the various pragma's (pragma index_info doesn't give you the 'partial' part of a partial index, pragma tablexinfo doesn't give you the expression for generated columns) so I need to parse the create table/create index statement. Was using python-sqlparser but that one couldn't parse 'generated always as' I assume because it isn't standard sql. Also sqlparser is very verbose so was looking for something more simple and sqlite only.

iafisher commented 2 years ago

Cool, that's similar to my original use-case, which was parsing create table statements so that isqlite could do database migrations.

iafisher commented 2 years ago

Okay, I fixed this and released it to PyPI as version 0.6.1 along with the other fix..

luxint commented 2 years ago

Great!! One nitpick, the parser doesn't recognise the || operator, only way in sqlite to concatenate strings..

iafisher commented 2 years ago

Fixed.