4 ms·
Well, you would put SQL inside a string in Python. PyCharm/IntelliJ already recognize that: as I write execute("SELECT... ") it considers the string PostgreSQL
by Erwin 12y ago
Well, you would put SQL inside a string in Python. PyCharm/IntelliJ already recognize that: as I write execute("SELECT... ") it considers the string PostgreSQL and autocompletes among the table names in my project's database; and If I write ("SELECT foo FROM bar") if the bar table has no foo, it highlights foo just like it would a Python variable that was not defined.
Now interestingly when you are within that SQL string you can press Alt-Enter (the general key for some context sensitive magic) and open a new nested editor window with just the PostgreSQL fragment. Let's say that PostgreSQL fragment now itself embeds Python code again (now running server-side using PL/Python). Yep, you can tell it the string inside SQL is Python.. and open another window. I then added an XML string inside the Python inside SQL inside Python, however it wouldn't go any deeper. However it does give you the syntax highlighting and language-specific warnings in XML, PostgreSQL, Python within Postgresql and top level Python:
Beyond the first level however, I had to manually tell it that this string is Python.