{"id":859,"library":"duckdb","title":"DuckDB in-process database","description":"DuckDB is an in-process SQL OLAP (Online Analytical Processing) database management system designed for fast analytical queries directly within your Python application. It operates without a separate server, integrating seamlessly with the Python data ecosystem like Pandas and Polars. It is actively maintained with frequent releases, currently at version 1.5.1, and focuses on efficient data handling for large datasets.","status":"active","version":"1.5.1","language":"python","source_language":"en","source_url":"https://github.com/duckdb/duckdb-python","tags":["database","olap","sql","in-process","data-analytics","arrow","pandas","polars"],"install":[{"cmd":"pip install duckdb","lang":"bash","label":"Install DuckDB Python Package"}],"dependencies":[{"reason":"Minimum Python version required for the library.","package":"python","version":">=3.10.0"}],"imports":[{"note":"While 'from duckdb import connect' works, 'import duckdb' is more common as many functions (like duckdb.sql) operate on a default in-memory connection if no explicit connection object is created.","wrong":"from duckdb import connect","symbol":"duckdb","correct":"import duckdb"},{"note":"The `duckdb.typing` module was deprecated in 1.4.0 and removed in 1.5.0; use `duckdb.sqltypes` instead for type definitions.","wrong":"from duckdb import typing","symbol":"duckdb.sqltypes","correct":"from duckdb import sqltypes"},{"note":"The `duckdb.functional` module was deprecated in 1.4.0 and removed in 1.5.0; use `duckdb.func` instead for functional APIs.","wrong":"from duckdb import functional","symbol":"duckdb.func","correct":"from duckdb import func"}],"quickstart":{"code":"import duckdb\n\n# Connect to an in-memory database (data is lost after session)\ncon = duckdb.connect(database=':memory:')\n\n# Execute a SQL query and show results\nresult = con.sql(\"SELECT 42 AS answer\").show()\n\n# Create a table and insert data\ncon.execute(\"CREATE TABLE my_table (id INTEGER, name VARCHAR)\")\ncon.execute(\"INSERT INTO my_table VALUES (1, 'Alice'), (2, 'Bob')\")\n\n# Query the table and fetch results as a Pandas DataFrame\ndf_result = con.sql(\"SELECT * FROM my_table WHERE id = 1\").df()\nprint(df_result)\n\n# Example of using the default global in-memory database\ndf_global = duckdb.sql(\"SELECT 'Hello, DuckDB!' AS message\").df()\nprint(df_global)","lang":"python","description":"This quickstart demonstrates how to connect to an in-memory DuckDB database, execute SQL queries, insert data, and retrieve results as a Pandas DataFrame. It also shows the convenience of using the default global in-memory database directly via `duckdb.sql()` for quick operations. For persistent storage, specify a file path in `duckdb.connect()`."},"warnings":[{"fix":"Upgrade your Python environment to version 3.10 or newer. DuckDB v1.5.0 requires Python >=3.10.0.","message":"Python 3.9 support has been dropped with DuckDB Python v1.5.0. Users on Python 3.9 will encounter errors.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"Replace imports and usage of `duckdb.typing` with `duckdb.sqltypes`, and `duckdb.functional` with `duckdb.func`.","message":"The `duckdb.typing` and `duckdb.functional` modules were removed in v1.5.0, having been deprecated in v1.4.0.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"Use the new `to_arrow_table()` and `to_arrow_reader()` methods instead for Arrow export APIs.","message":"The methods `fetch_arrow_table()` and `fetch_record_batch()` on connections and relations have been deprecated.","severity":"deprecated","affected_versions":">=1.5.0"},{"fix":"If you encounter this, load the old database file with the DuckDB version that created it, `EXPORT DATABASE` to a new location, then `IMPORT DATABASE` with the newer DuckDB version. After DuckDB v0.10, the storage format is backwards-compatible.","message":"DuckDB's persistent storage format is not stable across major/minor versions prior to v1.0. Upgrading DuckDB can lead to `IOException` when trying to read older database files.","severity":"gotcha","affected_versions":"<1.0 (historical issue, but relevant for older persisted data)"},{"fix":"Update calls to these relational API functions to use `expression` instead of `column`.","message":"The `column` parameter in relational API functions (e.g., `min`, `max`, `sum`) was renamed to `expression` to better reflect that it accepts expressions, not just column names.","severity":"gotcha","affected_versions":">=1.5.0"},{"fix":"Transition to the new Python-style lambda syntax: `lambda x: x + 1`. You can configure `lambda_syntax` to change behavior.","message":"The lambda arrow syntax `x -> x + 1` in SQL queries is deprecated in v1.5.0 and will emit a warning.","severity":"deprecated","affected_versions":">=1.5.0"},{"fix":"Install necessary build tools like `g++` and `cmake` in your environment before attempting to install `duckdb`. For Alpine Linux, this typically involves `apk add build-base cmake`.","message":"Building `duckdb` from source requires a C++ compiler (like `g++`) and potentially other build tools (e.g., `cmake`). Minimal environments like Alpine Linux often lack these by default, leading to build failures.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-12T20:30:05.272Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"Install the latest Microsoft Visual C++ Redistributable package from Microsoft's website. Alternatively, force pip to compile DuckDB from source using `python3 -m pip install duckdb --no-binary duckdb` (this requires a C++ compiler).","cause":"This error typically occurs on Windows when the necessary Microsoft Visual C++ Redistributable package is missing or outdated, which DuckDB's pre-compiled binaries (wheels) depend on.","error":"ImportError: DLL load failed while importing duckdb: The specified module could not be found."},{"fix":"Close the current DuckDB connection or session and then start a new connection to the database. If working with a persistent database file, DuckDB will attempt to replay the write-ahead log upon reconnection to restore the database to its state before the crash.","cause":"DuckDB enters a 'restricted mode' after encountering an internal error or crash, leaving the database in an undefined state and preventing further operations until restarted.","error":"FATAL Error: Failed: database has been invalidated because of a previous fatal error. The database must be restarted prior to being used again."},{"fix":"Ensure that the `duckdb.connect()` call is successful and returns a valid connection object. Check for any parameters passed to `connect()` (e.g., database file paths) that might be incorrect, and handle potential connection failures by verifying the returned object is not `None` before proceeding.","cause":"This error occurs when `duckdb.connect()` fails to establish a connection and returns `None`, and subsequent code attempts to call methods like `execute()` or `close()` on this `None` object.","error":"AttributeError: 'NoneType' object has no attribute 'execute'"},{"fix":"Ensure that only one process or connection is accessing the DuckDB database file at a time. If using multiple connections, ensure they are properly closed after use, or consider using in-memory databases (`:memory:`) or distinct file paths if concurrent access is truly needed (though DuckDB is designed for single-process, multi-threaded use with shared connections).","cause":"This error happens when multiple processes, applications, or even multiple connections within the same application attempt to open and write to the same DuckDB database file concurrently, leading to a file lock.","error":"IO Error: Cannot open file \"...\": The process cannot access the file because it is being used by another process."},{"fix":"Explicitly alias aggregated columns using the `.alias()` method immediately after the aggregation in the relational API, or use direct SQL queries with aliases to make the column names unambiguous for subsequent operations.","cause":"This typically occurs in the Python API when referencing a column that resulted from an aggregate function (e.g., 'sum(pnl)') within a chained relational API call, as DuckDB's binder might incorrectly interpret the string as an expression rather than a column name.","error":"BinderException: Binder Error: Referenced column \"...\" not found in FROM clause!"}],"ecosystem":"pypi","meta_description":null,"install_score":50,"install_tag":"draft","quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.5.2","cli_name":"duckdb","install_checks":{"last_tested":"2026-05-12","tag":"draft","tag_description":"notable install failures or slow imports","installed_version":"1.4.4","pypi_latest":"1.5.2","is_stale":true,"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"duckdb","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"duckdb","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"duckdb","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.2,"import_time_s":0.1,"mem_mb":3.9,"disk_size":"77M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"duckdb","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":3.9,"disk_size":"77M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"duckdb","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"duckdb","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"duckdb","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.2,"import_time_s":0.14,"mem_mb":4.5,"disk_size":"79M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"duckdb","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.15,"mem_mb":4.5,"disk_size":"79M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"duckdb","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"duckdb","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"duckdb","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2,"import_time_s":0.17,"mem_mb":5.1,"disk_size":"71M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"duckdb","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.17,"mem_mb":5.1,"disk_size":"71M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"duckdb","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"duckdb","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"duckdb","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2,"import_time_s":0.16,"mem_mb":5.1,"disk_size":"70M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"duckdb","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.15,"mem_mb":5.1,"disk_size":"70M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"duckdb","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"duckdb","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"duckdb","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.6,"import_time_s":0.1,"mem_mb":3.7,"disk_size":"74M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"duckdb","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":3.7,"disk_size":"74M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}