Closed panwlodek closed 11 months ago
Could you give an example on how to reproduce this error?
So far, everything seems fine:
>>> import sqlparse
>>> sql = """CREATE TABLE public."tp_timeentry" (
... id integer NOT NULL,
... line_no integer,
... date date NOT NULL,
... worked double precision NOT NULL,
... billable double precision NOT NULL,
... comment text NOT NULL,
... sub_account_id integer NOT NULL,
... time_file_id integer NOT NULL,
... CONSTRAINT "tp_timeentry_line_no_check" CHECK ((line_no >= 0))
... );"""
>>> p = sqlparse.parse(sql)[0]
>>> p
<Statement 'CREATE...' at 0x111F3D8C0>
Hi Andy, you have right, the some answer have I if I try to call it directly with sqlparse like you described in your answer. The error, that I saw is coming by calling of pg_diagram and because the pg_diagram use the sqlparse I thought, that is the error from sqlparse. Sorry
@panwlodek thanks for the feedback!
In my Version of sqlparse (0.4.4) is an error comming by the analyse of statements, with CONSTRAINT and CHECK f.e.:
CREATE TABLE public."tp_timeentry" ( id integer NOT NULL, line_no integer, date date NOT NULL, worked double precision NOT NULL, billable double precision NOT NULL, comment text NOT NULL, sub_account_id integer NOT NULL, time_file_id integer NOT NULL, CONSTRAINT "tp_timeentry_line_no_check" CHECK ((line_no >= 0)) );
The error message is following: Could not parse statement: (and the statement above)