adbc_driver_manager
#
Low-Level API#
Low-level ADBC bindings for Python.
The root module provides a fairly direct, 1:1 mapping to the C API
definitions in Python. For a higher-level interface, use
adbc_driver_manager.dbapi
. (This requires PyArrow.)
Constants & Enums#
- class adbc_driver_manager.AdbcStatusCode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntEnum
A status code indicating the type of error.
- Attributes:
denominator
the denominator of a rational number in lowest terms
imag
the imaginary part of a complex number
numerator
the numerator of a rational number in lowest terms
real
the real part of a complex number
Methods
as_integer_ratio
(/)Return integer ratio.
bit_count
(/)Number of ones in the binary representation of the absolute value of self.
bit_length
(/)Number of bits necessary to represent self in binary.
conjugate
Returns self, the complex conjugate of any int.
from_bytes
(/, bytes[, byteorder, signed])Return the integer represented by the given array of bytes.
to_bytes
(/[, length, byteorder, signed])Return an array of bytes representing an integer.
- ALREADY_EXISTS = 4#
- CANCELLED = 11#
- INTEGRITY = 8#
- INTERNAL = 9#
- INVALID_ARGUMENT = 5#
- INVALID_DATA = 7#
- INVALID_STATE = 6#
- IO = 10#
- NOT_FOUND = 3#
- NOT_IMPLEMENTED = 2#
- OK = 0#
- TIMEOUT = 12#
- UNAUTHENTICATED = 13#
- UNAUTHORIZED = 14#
- UNKNOWN = 1#
- class adbc_driver_manager.GetObjectsDepth(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntEnum
- Attributes:
denominator
the denominator of a rational number in lowest terms
imag
the imaginary part of a complex number
numerator
the numerator of a rational number in lowest terms
real
the real part of a complex number
Methods
as_integer_ratio
(/)Return integer ratio.
bit_count
(/)Number of ones in the binary representation of the absolute value of self.
bit_length
(/)Number of bits necessary to represent self in binary.
conjugate
Returns self, the complex conjugate of any int.
from_bytes
(/, bytes[, byteorder, signed])Return the integer represented by the given array of bytes.
to_bytes
(/[, length, byteorder, signed])Return an array of bytes representing an integer.
- ALL = 0#
- CATALOGS = 1#
- COLUMNS = 0#
- DB_SCHEMAS = 2#
- TABLES = 3#
- class adbc_driver_manager.ConnectionOptions(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
Enum
Connection options that are standardized between drivers.
Not all drivers support all options.
- CURRENT_CATALOG = 'adbc.connection.catalog'#
Get/set the current catalog.
- CURRENT_DB_SCHEMA = 'adbc.connection.db_schema'#
Get/set the current schema.
- ISOLATION_LEVEL = 'adbc.connection.transaction.isolation_level'#
Set the transaction isolation level.
- class adbc_driver_manager.DatabaseOptions(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
Enum
Database options that are standardized between drivers.
Not all drivers support all options.
- PASSWORD = 'password'#
Set the password to use for username-password authentication.
- URI = 'uri'#
The URI to connect to.
- USERNAME = 'username'#
Set the username to use for username-password authentication.
- class adbc_driver_manager.StatementOptions(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
Enum
Statement options that are standardized between drivers.
Not all drivers support all options.
- INCREMENTAL = 'adbc.statement.exec.incremental'#
Enable incremental execution on ExecutePartitions.
- INGEST_MODE = 'adbc.ingest.mode'#
For bulk ingestion, whether to create or append to the table.
- INGEST_TARGET_CATALOG = 'adbc.ingest.target_catalog'#
For bulk ingestion, the catalog to create/locate the table in. This API is EXPERIMENTAL.
- INGEST_TARGET_DB_SCHEMA = 'adbc.ingest.target_db_schema'#
For bulk ingestion, the schema to create/locate the table in. This API is EXPERIMENTAL.
- INGEST_TARGET_TABLE = 'adbc.ingest.target_table'#
For bulk ingestion, the table to ingest into.
- INGEST_TEMPORARY = 'adbc.ingest.temporary'#
For bulk ingestion, use a temporary table. This API is EXPERIMENTAL.
- PROGRESS = 'adbc.statement.exec.progress'#
Get progress of a query.
- adbc_driver_manager.INGEST_OPTION_MODE#
Whether to append to or create a new table for bulk ingestion.
- adbc_driver_manager.INGEST_OPTION_MODE_APPEND#
Append to the table for bulk ingestion.
- adbc_driver_manager.INGEST_OPTION_MODE_CREATE#
Create a new table for bulk ingestion.
- adbc_driver_manager.INGEST_OPTION_TARGET_TABLE#
The table to create/append to for bulk ingestion.
Classes#
- class adbc_driver_manager.AdbcConnection#
Bases:
_AdbcHandle
An active database connection.
Connections are not thread-safe and clients should take care to serialize accesses to a connection.
- Parameters:
- databaseAdbcDatabase
The database to connect to.
- kwargsdict
String key-value options to pass to the underlying database.
Methods
cancel
()Attempt to cancel any ongoing operations on the connection.
close
()Release the handle to the connection.
commit
()Commit the current transaction.
get_info
([info_codes])Get metadata about the database/driver.
get_objects
(depth[, catalog, db_schema, ...])Get a hierarchical view of database objects.
get_option
(key, *[, encoding, errors])Get the value of a string option.
get_option_bytes
(key)Get the value of a binary option.
get_option_float
(key)Get the value of a floating-point option.
get_option_int
(key)Get the value of an integer option.
get_table_schema
(catalog, db_schema, table_name)Get the Arrow schema of a table.
Get the list of supported table types.
read_partition
(partition)Fetch a single partition from execute_partitions.
rollback
()Rollback the current transaction.
set_autocommit
(enabled)Toggle whether autocommit is enabled.
set_options
(**kwargs)Set arbitrary key-value options.
- cancel() None #
Attempt to cancel any ongoing operations on the connection.
- close() None #
Release the handle to the connection.
- commit() None #
Commit the current transaction.
- get_info(info_codes=None) ArrowArrayStreamHandle #
Get metadata about the database/driver.
- get_objects(depth, catalog=None, db_schema=None, table_name=None, table_types=None, column_name=None) ArrowArrayStreamHandle #
Get a hierarchical view of database objects.
- get_option(key: str | bytes, *, encoding='utf-8', errors='strict') str #
Get the value of a string option.
- Parameters:
- keystr or bytes
The option to get.
- encodingstr
The encoding of the option value. This should almost always be UTF-8.
- errorsstr
What to do about errors when decoding the option value (see bytes.decode).
- get_option_bytes(key: str) bytes #
Get the value of a binary option.
- get_option_float(key: str) float #
Get the value of a floating-point option.
- get_option_int(key: str) int #
Get the value of an integer option.
- get_table_schema(catalog, db_schema, table_name) ArrowSchemaHandle #
Get the Arrow schema of a table.
- Returns:
- ArrowSchemaHandle
A C Data Interface ArrowSchema struct containing the schema.
- get_table_types() ArrowArrayStreamHandle #
Get the list of supported table types.
- read_partition(partition) ArrowArrayStreamHandle #
Fetch a single partition from execute_partitions.
- rollback() None #
Rollback the current transaction.
- set_autocommit(enabled) None #
Toggle whether autocommit is enabled.
- set_options(**kwargs) None #
Set arbitrary key-value options.
Pass options as kwargs:
set_options(**{"some.option": "value"})
.Note, not all drivers support setting options after creation.
See also
adbc_driver_manager.ConnectionOptions
Standard option names.
- class adbc_driver_manager.AdbcDatabase#
Bases:
_AdbcHandle
An instance of a database.
- Parameters:
- kwargsdict
String key-value options to pass to the underlying database. Must include at least “driver” to identify the underlying database driver to load.
Methods
close
()Release the handle to the database.
get_option
(key, *[, encoding, errors])Get the value of a string option.
get_option_bytes
(key)Get the value of a binary option.
get_option_float
(key)Get the value of a floating-point option.
get_option_int
(key)Get the value of an integer option.
set_options
(**kwargs)Set arbitrary key-value options.
- close() None #
Release the handle to the database.
- get_option(key: str | bytes, *, encoding='utf-8', errors='strict') str #
Get the value of a string option.
- Parameters:
- keystr or bytes
The option to get.
- encodingstr
The encoding of the option value. This should almost always be UTF-8.
- errorsstr
What to do about errors when decoding the option value (see bytes.decode).
- get_option_bytes(key: str) bytes #
Get the value of a binary option.
- get_option_float(key: str) float #
Get the value of a floating-point option.
- get_option_int(key: str) int #
Get the value of an integer option.
- set_options(**kwargs) None #
Set arbitrary key-value options.
Pass options as kwargs:
set_options(**{"some.option": "value"})
.Note, not all drivers support setting options after creation.
See also
adbc_driver_manager.DatabaseOptions
Standard option names.
- class adbc_driver_manager.AdbcStatement#
Bases:
_AdbcHandle
A database statement.
Statements are not thread-safe and clients should take care to serialize accesses to a connection.
- Parameters:
- connectionAdbcConnection
The connection to create the statement for.
Methods
bind
(data, schema)Bind an ArrowArray to this statement.
bind_stream
(stream)Bind an ArrowArrayStream to this statement.
cancel
()Attempt to cancel any ongoing operations on the connection.
close
()Release the handle to the statement.
Execute the query and get the partitions of the result set.
Execute the query and get the result set.
Get the schema of the result set without executing the query.
Execute the query without a result set.
get_option
(key, *[, encoding, errors])Get the value of a string option.
get_option_bytes
(key)Get the value of a binary option.
get_option_float
(key)Get the value of a floating-point option.
get_option_int
(key)Get the value of an integer option.
Get the Arrow schema for bound parameters.
prepare
()Turn this statement into a prepared statement.
set_options
(**kwargs)Set arbitrary key-value options for this statement only.
set_sql_query
(query)Set a SQL query to be executed.
set_substrait_plan
(plan)Set a Substrait plan to be executed.
- bind(data, schema) None #
Bind an ArrowArray to this statement.
- Parameters:
- dataint or ArrowArrayHandle
- schemaint or ArrowSchemaHandle
- bind_stream(stream) None #
Bind an ArrowArrayStream to this statement.
- Parameters:
- streamint or ArrowArrayStreamHandle
- cancel() None #
Attempt to cancel any ongoing operations on the connection.
- close() None #
Release the handle to the statement.
- execute_partitions() Tuple[List[bytes], ArrowSchemaHandle, int] #
Execute the query and get the partitions of the result set.
Not all drivers will support this.
- Returns:
- list of byte
The partitions of the distributed result set.
- ArrowSchemaHandle
The schema of the result set.
- int
The number of rows if known, else -1.
- execute_query() Tuple[ArrowArrayStreamHandle, int] #
Execute the query and get the result set.
- Returns:
- ArrowArrayStreamHandle
The result set.
- int
The number of rows if known, else -1.
- execute_schema() ArrowSchemaHandle #
Get the schema of the result set without executing the query.
- Returns:
- ArrowSchemaHandle
The schema of the result set.
- execute_update() int #
Execute the query without a result set.
- Returns:
- int
The number of affected rows if known, else -1.
- get_option(key: str | bytes, *, encoding='utf-8', errors='strict') str #
Get the value of a string option.
- Parameters:
- keystr or bytes
The option to get.
- encodingstr
The encoding of the option value. This should almost always be UTF-8.
- errorsstr
What to do about errors when decoding the option value (see bytes.decode).
- get_option_bytes(key: str) bytes #
Get the value of a binary option.
- get_option_float(key: str) float #
Get the value of a floating-point option.
- get_option_int(key: str) int #
Get the value of an integer option.
- get_parameter_schema() ArrowSchemaHandle #
Get the Arrow schema for bound parameters.
This retrieves an Arrow schema describing the number, names, and types of the parameters in a parameterized statement. The fields of the schema should be in order of the ordinal position of the parameters; named parameters should appear only once.
If the parameter does not have a name, or the name cannot be determined, the name of the corresponding field in the schema will be an empty string. If the type cannot be determined, the type of the corresponding field will be NA (NullType).
This should be called after
prepare()
.- Raises:
- NotSupportedError
If the schema could not be determined.
- prepare() None #
Turn this statement into a prepared statement.
- set_options(**kwargs) None #
Set arbitrary key-value options for this statement only.
Pass options as kwargs:
set_options(**{"some.option": "value"})
.Note, not all drivers support setting options after creation.
See also
adbc_driver_manager.StatementOptions
Standard option names.
- set_sql_query(query) None #
Set a SQL query to be executed.
- set_substrait_plan(plan) None #
Set a Substrait plan to be executed.
- class adbc_driver_manager.ArrowArrayHandle#
Bases:
object
A wrapper for an allocated ArrowArray.
- Attributes:
address
The address of the ArrowArray.
- address#
The address of the ArrowArray.
DBAPI 2.0 API#
PEP 249 (DB-API 2.0) API wrapper for the ADBC Driver Manager.
Resource Management#
You must close()
Connection and Cursor objects, or else driver
resources may be leaked. A __del__
is implemented as a fallback,
but Python does not guarantee the timing of when this is called. For
development, __del__
will raise a ResourceWarning when running
under pytest, or when the environment variable
_ADBC_DRIVER_MANAGER_WARN_UNCLOSED_RESOURCE
is set to 1
.
Constants & Enums#
- adbc_driver_manager.dbapi.apilevel = '2.0'#
The DB-API API level (2.0).
- adbc_driver_manager.dbapi.paramstyle = 'qmark'#
The parameter style (qmark). This is hardcoded, but actually depends on the driver.
- adbc_driver_manager.dbapi.threadsafety = 1#
The thread safety level (connections may not be shared).
- adbc_driver_manager.dbapi.Date = <class 'datetime.date'>#
The type for date values.
- adbc_driver_manager.dbapi.Time = <class 'datetime.time'>#
The type for time values.
- adbc_driver_manager.dbapi.Timestamp(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]]) = <class 'datetime.datetime'>#
The type for timestamp values.
- adbc_driver_manager.dbapi.BINARY = frozenset({14, 35})#
The type of binary columns.
- adbc_driver_manager.dbapi.DATETIME = frozenset({16, 17, 18, 19, 20})#
The type of datetime columns.
- adbc_driver_manager.dbapi.NUMBER = frozenset({2, 3, 4, 5, 6, 7, 8, 9, 11, 12})#
The type of numeric columns.
- adbc_driver_manager.dbapi.ROWID = frozenset({9})#
The type of “row ID” columns.
- adbc_driver_manager.dbapi.STRING = frozenset({13, 34})#
The type of string columns.
Functions#
- adbc_driver_manager.dbapi.connect(*, driver: str, entrypoint: str | None = None, db_kwargs: Dict[str, str] | None = None, conn_kwargs: Dict[str, str] | None = None, autocommit=False) Connection #
Connect to a database via ADBC.
- Parameters:
- driver
The driver name. For example, “adbc_driver_sqlite” will attempt to load libadbc_driver_sqlite.so on Linux systems, libadbc_driver_sqlite.dylib on MacOS, and adbc_driver_sqlite.dll on Windows. This may also be a path to the library to load.
- entrypoint
The driver-specific entrypoint, if different than the default.
- db_kwargs
Key-value parameters to pass to the driver to initialize the database.
- conn_kwargs
Key-value parameters to pass to the driver to initialize the connection.
- autocommit
Whether to enable autocommit. For compliance with DB-API, this is disabled by default. A warning will be emitted if it cannot be disabled.
- adbc_driver_manager.dbapi.DateFromTicks(ticks: int) date #
Construct a date value from a count of seconds.
- adbc_driver_manager.dbapi.TimeFromTicks(ticks: int) time #
Construct a time value from a count of seconds.
- adbc_driver_manager.dbapi.TimestampFromTicks(ticks: int) datetime #
Construct a timestamp value from a count of seconds.
Classes#
- class adbc_driver_manager.dbapi.Connection(db: AdbcDatabase | _SharedDatabase, conn: AdbcConnection, conn_kwargs: Dict[str, str] | None = None, *, autocommit=False)#
Bases:
_Closeable
A DB-API 2.0 (PEP 249) connection.
Do not create this object directly; use connect().
- Attributes:
adbc_connection
Get the underlying ADBC connection.
adbc_current_catalog
The name of the current catalog.
adbc_current_db_schema
The name of the current schema.
adbc_database
Get the underlying ADBC database.
Methods
Cancel any ongoing operations on this connection.
Create a new Connection sharing the same underlying database.
Get metadata about the database and driver.
adbc_get_objects
(*[, depth, catalog_filter, ...])List catalogs, schemas, tables, etc.
adbc_get_table_schema
(table_name, *[, ...])Get the Arrow schema of a table by name.
List the types of tables that the server knows about.
close
()Close the connection.
commit
()Explicitly commit.
cursor
()Create a new cursor for querying the database.
rollback
()Explicitly rollback.
- adbc_cancel() None #
Cancel any ongoing operations on this connection.
Notes
This is an extension and not part of the DBAPI standard.
- adbc_clone() Connection #
Create a new Connection sharing the same underlying database.
Notes
This is an extension and not part of the DBAPI standard.
- property adbc_connection: AdbcConnection#
Get the underlying ADBC connection.
Notes
This is an extension and not part of the DBAPI standard.
- property adbc_current_catalog: str#
The name of the current catalog.
Notes
This is an extension and not part of the DBAPI standard.
- property adbc_current_db_schema: str#
The name of the current schema.
Notes
This is an extension and not part of the DBAPI standard.
- property adbc_database: AdbcDatabase#
Get the underlying ADBC database.
Notes
This is an extension and not part of the DBAPI standard.
- adbc_get_info() Dict[str | int, Any] #
Get metadata about the database and driver.
Notes
This is an extension and not part of the DBAPI standard.
- adbc_get_objects(*, depth: Literal['all', 'catalogs', 'db_schemas', 'tables', 'columns'] = 'all', catalog_filter: str | None = None, db_schema_filter: str | None = None, table_name_filter: str | None = None, table_types_filter: List[str] | None = None, column_name_filter: str | None = None) RecordBatchReader #
List catalogs, schemas, tables, etc. in the database.
- Parameters:
- depth
What objects to return info on.
- catalog_filter
An optional filter on the catalog names returned.
- db_schema_filter
An optional filter on the database schema names returned.
- table_name_filter
An optional filter on the table names returned.
- table_types_filter
An optional list of types of tables returned.
- column_name_filter
An optional filter on the column names returned.
Notes
This is an extension and not part of the DBAPI standard.
- adbc_get_table_schema(table_name: str, *, catalog_filter: str | None = None, db_schema_filter: str | None = None) Schema #
Get the Arrow schema of a table by name.
- Parameters:
- table_name
The table to get the schema of.
- catalog_filter
An optional filter on the catalog name of the table.
- db_schema_filter
An optional filter on the database schema name of the table.
Notes
This is an extension and not part of the DBAPI standard.
- adbc_get_table_types() List[str] #
List the types of tables that the server knows about.
Notes
This is an extension and not part of the DBAPI standard.
- close() None #
Close the connection.
Warning
Failure to close a connection may leak memory or database connections.
- commit() None #
Explicitly commit.
- rollback() None #
Explicitly rollback.
- class adbc_driver_manager.dbapi.Cursor(conn: Connection)#
Bases:
_Closeable
A DB-API 2.0 (PEP 249) cursor.
Do not create this object directly; use Connection.cursor().
- Attributes:
adbc_statement
Get the underlying ADBC statement.
arraysize
The number of rows to fetch at a time with fetchmany().
connection
Get the connection associated with this cursor.
description
The schema of the result set.
rowcount
Get the row count of the result set, or -1 if not known.
rownumber
Get the current row number, or None if not applicable.
Methods
Cancel any ongoing operations on this statement.
adbc_execute_partitions
(operation[, parameters])Execute a query and get the partitions of a distributed result set.
adbc_execute_schema
(operation[, parameters])Get the schema of the result set of a query without executing it.
adbc_ingest
(table_name, data[, mode, ...])Ingest Arrow data into a database table.
adbc_prepare
(operation)Prepare a query without executing it.
adbc_read_partition
(partition)Read a partition of a distributed result set.
callproc
(procname, parameters)Call a stored procedure (not supported).
close
()Close the cursor and free resources.
execute
(operation[, parameters])Execute a query.
executemany
(operation, seq_of_parameters)Execute a query with multiple parameter sets.
executescript
(operation)Execute multiple statements.
Fetch all rows of the result as a PyArrow Table.
fetch_df
()Fetch all rows of the result as a Pandas DataFrame.
Fetch the result as a PyArrow RecordBatchReader.
fetchall
()Fetch all rows of the result.
Fetch all rows of the result as a PyArrow Table.
fetchmany
([size])Fetch some rows of the result.
fetchone
()Fetch one row of the result.
next
()Fetch the next row, or raise StopIteration.
nextset
()Move to the next available result set (not supported).
setinputsizes
(sizes)Preallocate memory for the parameters (no-op).
setoutputsize
(size[, column])Preallocate memory for the result set (no-op).
- adbc_cancel() None #
Cancel any ongoing operations on this statement.
Notes
This is an extension and not part of the DBAPI standard.
- adbc_execute_partitions(operation, parameters=None) Tuple[List[bytes], Schema] #
Execute a query and get the partitions of a distributed result set.
- Returns:
- partitionslist of byte
A list of partition descriptors, which can be read with read_partition.
- schemapyarrow.Schema
The schema of the result set.
Notes
This is an extension and not part of the DBAPI standard.
- adbc_execute_schema(operation, parameters=None) Schema #
Get the schema of the result set of a query without executing it.
- Returns:
- pyarrow.Schema
The schema of the result set.
Notes
This is an extension and not part of the DBAPI standard.
- adbc_ingest(table_name: str, data: RecordBatch | Table | RecordBatchReader, mode: Literal['append', 'create', 'replace', 'create_append'] = 'create', *, catalog_name: str | None = None, db_schema_name: str | None = None, temporary: bool = False) int #
Ingest Arrow data into a database table.
Depending on the driver, this can avoid per-row overhead that would result from a typical prepare-bind-insert loop.
- Parameters:
- table_name
The table to insert into.
- data
The Arrow data to insert.
- mode
How to deal with existing data:
‘append’: append to a table (error if table does not exist)
‘create’: create a table and insert (error if table exists)
‘create_append’: create a table (if not exists) and insert
‘replace’: drop existing table (if any), then same as ‘create’
- catalog_name
If given, the catalog to create/locate the table in. This API is EXPERIMENTAL.
- db_schema_name
If given, the schema to create/locate the table in. This API is EXPERIMENTAL.
- temporary
Whether to ingest to a temporary table or not. Most drivers will not support setting this along with catalog_name and/or db_schema_name. This API is EXPERIMENTAL.
- Returns:
- int
The number of rows inserted, or -1 if the driver cannot provide this information.
Notes
This is an extension and not part of the DBAPI standard.
- adbc_prepare(operation: bytes | str) Schema | None #
Prepare a query without executing it.
To execute the query afterwards, call
execute()
orexecutemany()
with the same query. This will not prepare the query a second time.- Returns:
- pyarrow.Schema or None
The schema of the bind parameters, or None if the schema could not be determined.
Notes
This is an extension and not part of the DBAPI standard.
- adbc_read_partition(partition: bytes) None #
Read a partition of a distributed result set.
Notes
This is an extension and not part of the DBAPI standard.
- property adbc_statement: AdbcStatement#
Get the underlying ADBC statement.
Notes
This is an extension and not part of the DBAPI standard.
- property arraysize: int#
The number of rows to fetch at a time with fetchmany().
- callproc(procname, parameters)#
Call a stored procedure (not supported).
- close()#
Close the cursor and free resources.
- property connection: Connection#
Get the connection associated with this cursor.
This is an optional DB-API extension.
- property description: List[tuple] | None#
The schema of the result set.
- execute(operation: bytes | str, parameters=None) None #
Execute a query.
- Parameters:
- operationbytes or str
The query to execute. Pass SQL queries as strings, (serialized) Substrait plans as bytes.
- parameters
Parameters to bind. Can be a Python sequence (to provide a single set of parameters), or an Arrow record batch, table, or record batch reader (to provide multiple parameters, which will each be bound in turn).
- executemany(operation: bytes | str, seq_of_parameters) None #
Execute a query with multiple parameter sets.
This method does not generate a result set.
- Parameters:
- operationbytes or str
The query to execute. Pass SQL queries as strings, (serialized) Substrait plans as bytes.
- parameters
Parameters to bind. Can be a list of Python sequences, or an Arrow record batch, table, or record batch reader. If None, then the query will be executed once, else it will be executed once per row.
- executescript(operation: str) None #
Execute multiple statements.
If there is a pending transaction, commits first.
Notes
This is an extension and not part of the DBAPI standard.
- fetch_arrow_table() Table #
Fetch all rows of the result as a PyArrow Table.
This implements a similar API as DuckDB.
Notes
This is an extension and not part of the DBAPI standard.
- fetch_df() pandas.DataFrame #
Fetch all rows of the result as a Pandas DataFrame.
This implements a similar API as DuckDB.
Notes
This is an extension and not part of the DBAPI standard.
- fetch_record_batch() RecordBatchReader #
Fetch the result as a PyArrow RecordBatchReader.
This implements a similar API as DuckDB: https://duckdb.org/docs/guides/python/export_arrow.html#export-as-a-recordbatchreader
Notes
This is an extension and not part of the DBAPI standard.
- fetchall() List[tuple] #
Fetch all rows of the result.
- fetchallarrow() Table #
Fetch all rows of the result as a PyArrow Table.
This implements a similar API as turbodbc.
Notes
This is an extension and not part of the DBAPI standard.
- fetchmany(size: int | None = None) List[tuple] #
Fetch some rows of the result.
- fetchone() tuple | None #
Fetch one row of the result.
- next()#
Fetch the next row, or raise StopIteration.
- nextset()#
Move to the next available result set (not supported).
- property rowcount: int#
Get the row count of the result set, or -1 if not known.
- property rownumber: int | None#
Get the current row number, or None if not applicable.
- setinputsizes(sizes)#
Preallocate memory for the parameters (no-op).
- setoutputsize(size, column=None)#
Preallocate memory for the result set (no-op).
Exceptions#
- exception adbc_driver_manager.DatabaseError(message, *, status_code, vendor_code=None, sqlstate=None, details=None)#
Bases:
Error
Errors related to the database.
- exception adbc_driver_manager.DataError(message, *, status_code, vendor_code=None, sqlstate=None, details=None)#
Bases:
DatabaseError
Errors related to processed data.
- exception adbc_driver_manager.Error(message, *, status_code, vendor_code=None, sqlstate=None, details=None)#
Bases:
Exception
PEP 249-compliant base exception class.
- Attributes:
- status_codeAdbcStatusCode
The original ADBC status code.
- vendor_codeint, optional
A vendor-specific status code if present.
- sqlstatestr, optional
The SQLSTATE code if present.
- detailslist[tuple[str, bytes]], optional
Additional error details, if present.
- exception adbc_driver_manager.IntegrityError(message, *, status_code, vendor_code=None, sqlstate=None, details=None)#
Bases:
DatabaseError
Errors related to relational integrity.
- exception adbc_driver_manager.InterfaceError(message, *, status_code, vendor_code=None, sqlstate=None, details=None)#
Bases:
Error
Errors related to the database interface.
- exception adbc_driver_manager.InternalError(message, *, status_code, vendor_code=None, sqlstate=None, details=None)#
Bases:
DatabaseError
Errors related to database-internal errors.
- exception adbc_driver_manager.NotSupportedError(message, *, vendor_code=None, sqlstate=None, details=None)#
Bases:
DatabaseError
An operation or some functionality is not supported.
- exception adbc_driver_manager.OperationalError(message, *, status_code, vendor_code=None, sqlstate=None, details=None)#
Bases:
DatabaseError
Errors related to database operation, not under user control.
- exception adbc_driver_manager.ProgrammingError(message, *, status_code, vendor_code=None, sqlstate=None, details=None)#
Bases:
DatabaseError
Errors related to user errors.
- exception adbc_driver_manager.Warning#
Bases:
UserWarning
PEP 249-compliant base warning class.