On 10/22/2020 4:58 AM, Hans Ginzel wrote:
Hello,
consider this snippet please
cursor.execute(f"INSERT INTO {table} VALUES (1, '{}');")
SyntaxError: f-string: empty expression not allowed
It is (absolutely) correct to insert empty json into database table
field.
Empty expression in f-string should
* (silently) expand as '{}' (opening and closing braces),
* generate a (compile time) warning if requested, e.g. with -W.
You can use f"INSERT INTO {table} VALUES (1, '{{}}');".
The doubled braces become single braces inside an f-string.
Eric
_______________________________________________
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/MGUBJY53OZR5G22WT6OPBGCPQ2GB54ZO/
Code of Conduct: http://python.org/psf/codeofconduct/