psycopg2 here? I've tried a backtick, and multiple double quotes.
cur.execute(f"CREATE DATABASE `{dbname}` TEMPLATE template0 ENCODING 'UTF8'")
psycopg2.errors.SyntaxError: syntax error at or near "`"
LINE 1: CREATE DATABASE `crmpicco-sf440_31m` TEMPLATE template0 EN...
IIRC, database names don't require quotes. Have you tried it without any?
yes, the - is an issue. cur.execute(f"CREATE DATABASE {dbname} TEMPLATE template0 ENCODING 'UTF8'") psycopg2.errors.SyntaxError: syntax error at or near "-" LINE 1: CREATE DATABASE crmpicco-sf440_31m TEMPLATE template0 ENCO...
uh don't use f strings in database queries
yes, I absolutely agree. This has no public-facing, customer input though - it's an admin script only
Обсуждают сегодня