Python & DuckDB 1.0
I’m trying to copy a table to a parquet file with the filename passed as a parameter in a prepared statement.
Using a fixed filename works:
def table2parquet(con):
con.execute(
f"""
COPY
(SELECT ...)
TO
'table.parquet' (FORMAT PARQUET)
"""
)
But, passing the filename as a prepared statement parameter results in a syntax error:
def table2parquet(con, filename):
con.execute(
f"""
COPY
(SELECT ...)
TO
? (FORMAT PARQUET)
""",
[filename]
)
ParserException: Parser Error: syntax error at or near "?"
Is there a way to do this?
Many thanks