using sql statement in python
已回答
IntelliJ IDEA 2022.2.1 (Ultimate Edition)
Build #IU-222.3739.54, built on August 16, 2022
I'm using IDEA for python project that interact with postgresql database. I have database configured.
Using below sql statement as an example:
INSERT INTO some_table (id, created_at, last_name)
VALUES (%s, %s, %s);
If I put it in file test.sql, it can recognized table correctly but it shows error on %s: <expression> expected, got '%'.
If I put it in file test.py and assigned to a variable as multiple line string, then everything is ok but I lose the capability of formatting the sql statement.
sql = '''
INSERT INTO some_table (id, created_at, last_name)
VALUES (%s, %s, %s);
'''
What the best way to code sql statement with parameter in Intellij IDEA?
请先登录再写评论。
Hi Henry,
Please see and follow DBE-16219.