andialbrecht / sqlparse

A non-validating SQL parser module for Python
BSD 3-Clause "New" or "Revised" License
3.75k stars 699 forks source link

Parsing is not correct(Create table ~~). #353

Open jj4st13 opened 7 years ago

jj4st13 commented 7 years ago

query is "CREATE TABLE 'Student' ('id' INTEGER NOT NULL, 'name' TEXT NOT NULL, 'dgree' INTEGER NOT NULL, 'subject' TEXT NOT NULL, PRIMARY KEY(id));"

i run sqlparse.parse(query)

After parsing the query, the tokenizer will not return correctly.

The token group contains "NOT NULL, 'name'."

Is it working correctly?

I want to separate "NOT NULL, 'name'".

phdru commented 7 years ago

It's a result of incorrect grouping of lists separated by commas. See #66.

BrendanMartin commented 5 years ago

I'm having this problem now. Need to extract column names and types from CREATE TABLE definitions and the lines aren't split on commas correctly.