sqlparse icon indicating copy to clipboard operation
sqlparse copied to clipboard

A non-validating SQL parser module for Python

Results 194 sqlparse issues
Sort by recently updated
recently updated
newest added

it doesnt work for the example code to extract table name ``` SELECT Orders.OrderID, Customers.CustomerName, Shippers.ShipperName FROM ( (Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID) INNER JOIN Shippers ON...

When I try to use the formatter on the following SQL (valid in BigQuery) ``` select extract(date from cast(created_at as timestamp) at time zone 'America/New_York') as created_at from prod.orders ```...

I noticed that `sqlformat` will concatenate statements together when using `-a` (`--reindent_aligned`) to format files. Below is a screenshot to show the issue. Basically, after formatting the file, `sqlformat` simply...

The following minimal code yields an error. Code: ``` import sqlparse import copy query = 'SELECT * FROM adults WHERE age < 20' parsed = sqlparse.parse(query)[0] copied_parsed = copy.deepcopy(parsed) ```...

>>> import sqlparse >>> sql = '''SELECT a, row_number() OVER (partition by foo ORDER BY bar), b, c, d, e, f FROM c''' >>> print(sqlparse.format(sql, reindent=True)) This outputs the following...

In some cases (error reporting, syntax highlighting), it might be desired to know the location of the tokens w.r.t. the original input.

It is also possible to add the last comment to the upper statement. However maybe this solution fits. What is also possible is to add an option to leave comments...

When you encounter a SQL file which ends with a comment the split function will see it as a valid statement: ``` DROP TABLE IF EXISTS schema_a.table_a CASCADE; DROP TABLE...

Needs Feedback

Is there a reason why `IS NULL` keyword is not considered as comparison ? ``` >>> x = "something IS NULL" >>> parsed = sqlparse.parse(x)[0] >>> parsed.tokens [, , ,...

Ciao, I'm having a problem formatting a query with identifier_case = upper. It seems that the formatter cannot correctly recognize the name of an entity if its value is present...