- Installation
- What's New in the Docs for 2.0
- Documentation
- Getting Started
- Connect
- Data Import and Export
- Overview
- Data Sources
- CSV Files
- IO
- JSON Files
- Overview
- Creating JSON
- Loading JSON
- Writing JSON
- JSON Type
- JSON Functions
- Format Settings
- Installing and Loading
- SQL to / from JSON
- Caveats
- Multiple Files
- Parquet Files
- Partitioning
- Appender
- INSERT Statements
- Lakehouse Formats
- Client APIs
- Overview
- ADBC
- C
- Overview
- Startup
- Configuration
- Query
- Data Chunks
- Vectors
- Values
- Types
- Prepared Statements
- Appender
- Table Functions
- Replacement Scans
- API Reference
- C++
- CLI
- Overview
- Arguments
- Dot Commands
- Output Formats
- Agent Mode
- Editing
- Friendly CLI
- Safe Mode
- Autocomplete
- Syntax Highlighting
- Known Issues
- Go
- Overview
- Connect
- Import Data
- Run Queries
- Handle Results
- Write User Defined Functions
- Profile and Monitor
- Troubleshoot
- Java (JDBC)
- Overview
- Connect
- Import Data
- Run Queries
- Handle Results
- Write User Defined Functions
- Profile and Monitor
- Deploy as Native Image
- Troubleshoot
- Node.js (Neo)
- ODBC
- Python
- Overview
- Data Ingestion
- Appender
- Conversion between DuckDB and Python
- DB API
- Relational API
- Function API
- Types API
- Expression API
- Spark API
- API Reference
- Known Python Issues
- Migrating to 2.0
- R
- Rust
- Overview
- Connect
- Import Data
- Run Queries
- Handle Results
- Write User Defined Functions
- Profile and Monitor
- Troubleshoot
- Wasm
- Tertiary Clients
- SQL
- Introduction
- Statements
- Overview
- ANALYZE
- ALTER DATABASE
- ALTER TABLE
- ALTER VIEW
- ATTACH and DETACH
- CALL
- CHECKPOINT
- COMMENT ON
- CONNECT and DISCONNECT
- COPY
- CREATE INDEX
- CREATE MACRO
- CREATE SCHEMA
- CREATE SECRET
- CREATE SEQUENCE
- CREATE TABLE
- CREATE VIEW
- CREATE TRIGGER
- CREATE TYPE
- DELETE
- DESCRIBE
- DROP
- EXPORT and IMPORT DATABASE
- INSERT
- LOAD / INSTALL
- MERGE INTO
- PIVOT
- Profiling
- PREPARE, EXECUTE, and DEALLOCATE
- SELECT
- SET / RESET
- SET VARIABLE
- SHOW and SHOW DATABASES
- SUMMARIZE
- Transaction Management
- UNPIVOT
- UPDATE
- UPDATE EXTENSIONS
- USE
- VACUUM
- Query Syntax
- SELECT
- FROM and JOIN
- WHERE
- GROUP BY
- GROUPING SETS
- HAVING
- ORDER BY
- LIMIT and OFFSET
- SAMPLE
- Unnesting
- WITH
- WINDOW
- QUALIFY
- VALUES
- FILTER
- Set Operations
- Prepared Statements
- Data Types
- Overview
- Array
- Bitstring
- Blob
- Boolean
- Date
- Enum
- Geometry
- Interval
- List
- Literal Types
- Map
- NULL Values
- Numeric
- Struct
- Text
- Time
- Timestamp
- Time Zones
- Union
- Typecasting
- Variant
- Expressions
- Overview
- CASE Expression
- Casting
- Collations
- Comparisons
- IN Operator
- Logical Operators
- Star Expression
- Subqueries
- TRY
- Functions
- Overview
- Aggregate Functions
- Array Functions
- Bitstring Functions
- Blob Functions
- Date Format Functions
- Date Functions
- Date Part Functions
- Enum Functions
- Geometry Functions
- Interval Functions
- Lambda Functions
- List Functions
- Map Functions
- Nested Functions
- Numeric Functions
- Pattern Matching
- Regular Expressions
- Struct Functions
- Text Functions
- Time Functions
- Timestamp Functions
- Timestamp with Time Zone Functions
- Union Functions
- Utility Functions
- Variant Functions
- Window Functions
- Constraints
- Indexes
- Meta Queries
- DuckDB's SQL Dialect
- Overview
- Indexing
- Friendly SQL
- Keywords and Identifiers
- Order Preservation
- PostgreSQL Compatibility
- SQL Quirks
- PEG Parser
- Samples
- Configuration
- Extensions
- Overview
- Installing Extensions
- Advanced Installation Methods
- Distributing Extensions
- Extension Repositories
- Community Extensions
- Versioning of Extensions
- Troubleshooting of Extensions
- Core Extensions
- Overview
- AutoComplete
- Avro
- AWS
- Azure
- Delta
- DuckLake
- Encodings
- Excel
- Full Text Search
- httpfs (HTTP and S3)
- Overview
- HTTP(S) Support
- Hugging Face
- S3 API Support
- S3 and AWS Authentication
- Legacy Authentication Scheme for S3 API
- Iceberg
- ICU
- inet
- Lance
- Legacy Parser
- MotherDuck
- MySQL
- ODBC
- Quack
- PostgreSQL
- Sirius
- Spatial
- SQLite
- SQLSmith
- TPC-DS
- TPC-H
- UI
- Unity Catalog
- Vortex
- VSS
- Quack Remote Protocol
- Guides
- Overview
- Data Viewers
- Database Integration
- File Formats
- Overview
- CSV Import
- CSV Export
- Directly Reading Files
- Directly Reading DuckDB Databases
- Excel Import
- Excel Export
- JSON Import
- JSON Export
- Parquet Import
- Parquet Export
- Querying Parquet Files
- File Access with the file: Protocol
- Meta Queries
- Describe Table
- EXPLAIN: Inspect Query Plans
- EXPLAIN ANALYZE: Profile Queries
- List Tables
- Summarize
- DuckDB Environment
- Network and Cloud Storage
- Overview
- HTTP Parquet Import
- HTTP CSV Import
- S3 Parquet Import
- S3 Parquet Export
- S3 Iceberg Import
- S3 Express One
- GCS Import
- Cloudflare R2 Import
- DuckDB over HTTPS / S3
- Share a Views-Only Database
- Fastly Object Storage Import
- SeaweedFS Import
- Tigris Import
- ODBC
- Performance
- Overview
- Environment
- Import
- Schema
- Indexing
- Join Operations
- File Formats
- How to Tune Workloads
- My Workload Is Slow
- Out-of-Memory Issues
- Benchmarks
- Working with Huge Databases
- Python
- Installation
- Executing SQL
- Jupyter Notebooks
- marimo Notebooks
- SQL on Pandas
- Import from Pandas
- Export to Pandas
- Import from Numpy
- Export to Numpy
- SQL on Arrow
- Import from Arrow
- Export to Arrow
- Relational API on Pandas
- Multiple Python Threads
- Integration with Ibis
- Integration with Polars
- Integration with PyTorch
- Using fsspec Filesystems
- SQL Editors
- Beekeeper Studio SQL Editor
- DBeaver SQL IDE
- DBine SQL Editor
- LibreDB Studio SQL Editor
- VisuaLeaf SQL Editor
- SQL Features
- AsOf Join
- Full-Text Search
- Graph Queries
- query and query_table Functions
- Merge Statement for SCD Type 2
- Timestamp Issues
- Snippets
- Creating Synthetic Data
- Dutch Railway Datasets
- Sharing Macros
- Analyzing a Git Repository
- Importing Duckbox Tables
- Copying an In-Memory Database to a File
- Calculating a Database Checksum
- Troubleshooting
- Glossary of Terms
- Browsing Offline
- Operations Manual
- Overview
- Migrating to DuckDB v2.0
- Backup Extension Repositories
- DuckDB's Footprint
- Installing DuckDB
- Logging
- User Agents
- Securing DuckDB
- Non-Deterministic Behavior
- Limits
- DuckDB Docker Container
- Development
- Overview
- DuckDB Repositories
- Release Cycle
- Metrics
- Profiling
- Building DuckDB
- Overview
- Build Configuration
- Building Extensions
- Statically Linking Extensions
- Android
- Linux
- macOS
- Raspberry Pi
- Windows
- Python
- R
- Troubleshooting
- Unofficial and Unsupported Platforms
- Benchmark Suite
- Testing
- Overview
- sqllogictest Introduction
- Writing Tests
- Unit Tester Configuration
- Debugging
- Result Verification
- Persistent Testing
- Loops
- Multiple Connections
- Catch
- Internal Errors
- Internals
- Sitemap
- Live Demo
This page lists what Python code written for DuckDB 1.x must change to run on DuckDB 2.0. Each item gives the 1.x form, the 2.0 form and the page that explains it. For changes outside the Python client, see Migrating to DuckDB v2.0.
-
Python version. DuckDB 2.0 requires Python 3.11 or newer; free-threaded builds of CPython are not supported. On Python 3.10,
pip install duckdbinstalls a 1.x release. See Installation. -
Arrow and Polars output of
execute(). 1.x:con.execute(query).fetch_arrow_table(),fetch_record_batch(),arrow()andpl(). 2.0: these methods are gone fromexecute()results, andto_arrow_table()andto_arrow_reader()there copy the rows and warn. Use a relation:con.sql(query).to_arrow_table(),con.sql(query).to_arrow_reader()orcon.sql(query).pl(). See Arrow and Polars Output. -
Fetching from a relation. 1.x:
rel.fetchone(),rel.fetchmany(n),rel.execute()andrel.fetch_df_chunk(). 2.0: these methods are gone, because a relation keeps no result between calls and runs its query again on every read. To keep afetchone()orfetchmany()loop for a SQL query, create its result withcon.execute(query)instead ofcon.sql(query). To iterate over an existing relation, usefor row in rel.iter_rows(): ...; this keeps the complete result in engine memory. For streamed batches, userel.to_arrow_reader(). Replacerel.execute()withrel.materialize()when you want to compute and retain the rows. -
Plain strings in expressions. 1.x: in
ColumnExpression("s") == "x"and inrel.update(set={"a": "x"}), the string"x"named a column. 2.0: in an expression a plain string is a value, so the comparison testssagainst the textxand warns whenxis also a column name;update()refuses a plain string with aTypeError. Writecol("x")for the column andlit("x")for the text. See the Expression API andupdate. -
Dotted column names. 1.x:
ColumnExpression("t.x")was the columnxoft. 2.0: a name is never split at a dot, so"t.x"is one column name, and a query without a column of that name raises aBinderException. Writecol("t", "x"). See Column Expression. -
Dicts with keys that are not strings. 1.x:
con.values({1: "a"})made aSTRUCTwith a field named1. 2.0: invalues()and in expressions, such a dict becomes aMAP, hereMAP(INTEGER, VARCHAR). Use string keys for aSTRUCT. Seedict. -
Columns named like new relation methods. 1.x:
rel.offsetwas the columnoffsetofrel. 2.0: relations have new methods such asoffset,sample,head,rename,pivot,drop,unnest,unpivot,previewandgroup_by, sorel.offsetis the method. Writerel["offset"]for the column. See the Relational API. -
sql()of statements that do not read. 1.x:con.sql("CREATE TABLE t (i INTEGER)")returnedNone. 2.0: it returns a relation over what the statement returned, which a REPL or notebook prints; the statement still runs at the call. Usecon.execute()for DDL and DML. Printing a relation runs its query, every time. See Basic API Usage. -
Open
execute()results. 1.x: other queries on the connection ran while a result was partly read. 2.0: running another query on the connection raises aResourceInUseExceptionuntil the result is read to its end or ended withcon.complete()orcon.abort(), and the nextexecute()replaces the open result. See Open Results. -
One connection in several threads. 1.x: calls from several threads on one connection waited for each other. 2.0: a call while another thread uses the connection raises a
ResourceInUseException. Give each thread its owncon.cursor(). See Using Connections in Parallel Python Programs. -
Failed statements in a transaction. 1.x: after
con.begin(), a statement run withexecute()that failed with a catalog, binder or parser error left the transaction usable. 2.0: any statement run withexecute()that fails aborts the transaction:con.commit()then rolls it back, and any other statement raises aTransactionExceptionuntilcon.rollback(). See Transactions. -
Writing files with
overwrite=False. 1.x:rel.write_csv(path, overwrite=False)andrel.write_parquet(path, overwrite=False)replaced an existing file. 2.0: they raise anIOException. Leaveoverwriteout to replace the file. Seewrite_csvandwrite_parquet. -
Decimalvalues with a positive exponent. 1.x:Decimal("1E+2")became1.00of typeDECIMAL(3,2). 2.0: it is100of typeDECIMAL(3,0). See Conversion between DuckDB and Python. -
Arrow batch size. 1.x: the Arrow output of a relation came in batches of 1000000 rows by default. 2.0: the default is 131072 rows. Pass
batch_sizetoto_arrow_table()orto_arrow_reader()for another size. Seeto_arrow_reader. -
Database files. 1.x: a database file that DuckDB 1.5 wrote opens in DuckDB 1.5. 2.0: DuckDB 1.5 cannot open a file that DuckDB 2.0 writes in its default format; to keep a file readable by DuckDB 1.5, connect with
config={"storage_compatibility_version": "v1.5.0"}. See Configuration and Storage Format.