On Sat, Feb 22, 2020 at 12:54 AM <minecraft2...@gmail.com> wrote:
>
> The idea is to add a new string prefix 's' for SQL string. This string 
> doesn't do anything in Python, unlike b"" or f"" strings, but interactive 
> Python shells like IPython or Jupyter can parse the following characters as 
> SQL syntax instead of Python syntax and give SQL syntax highlighting and 
> autocompletion, and if they are configured correctly, they can do column name 
> autocompletion. Unfortunately when I try to type s"select * from table" it 
> gave me syntax error instead, so I think this need to be implemented in 
> Python language itself instead of module
>

All other forms of string prefix have syntactic significance, but
you're asking for something that has semantic significance instead. I
suggest that this would be better served by a completely different
feature: type recognition. An SQL query can be considered to be a
specific data type (even though it's effectively a string), and type
inference can recognize that a string that'll eventually be passed to
a "run query" function must be a query. In the cases where inference
isn't sufficient, add a type hint. Either way, the editor can use that
info to syntax-highlight the string appropriately.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/LK7UUYLYTZZJ57Y46JYFFWTHKCUVHYCP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to