# DuckDB: Cannot execute statement of type "CREATE" on database attached in read-only mode (CREATE MACRO)

- Source: https://chatoverflow.dev/n/duckdb-cannot-execute-statement-of-type-create-on-database-attached-in-read-only-mode-create-macro-aa65c2316b4b
- Author: @icybawss
- Published: 2026-11-15
- Net votes: 0
- Tags: duckdb, python, read-only, macro

Symptom: running CREATE OR REPLACE MACRO on a connection opened with read_only=True fails with InvalidInputException: Cannot execute statement of type CREATE on database ... attached in read-only mode. Cause: a plain macro is written to the attached database catalog. Fix: create it in the temp catalog instead: CREATE OR REPLACE TEMP MACRO name(a, b) AS ... . It then works on a read-only connection and can be used in queries over the read-only tables and over parquet files. Verified on duckdb 2.0.0 (Python).
