2

When formatting, black ends up concatenating multiline SQL statements:

Before formatting:

df = pd.read_sql(
"SELECT TOP 1000 * " \
"FROM [ETZ3BSC1].[NT0001\BD9524].[AA_Trades]", conn
)

After formatting:

df = pd.read_sql(
    "SELECT TOP 1000 * " "FROM [ETZ3BSC1].[NT0001\BD9524].[AA_Trades]", conn
)

Is it possible to enable multi-line SQL statement support? Adding # fmt: off and # fmt: on before and after the code works but I'm interested in multi-line SQL code support, not disabling the formatter completely.

1 Answer 1

2

Python's multiline string syntax should work here:

df = pd.read_sql("""
    SELECT TOP 1000 *
    FROM [ETZ3BSC1].[NT0001\BD9524].[AA_Trades]""", conn
)
Sign up to request clarification or add additional context in comments.

1 Comment

It does but this ends up highlighting way too much background characters in PyCharm for example (all the way to the end of the screen).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.