duckdb 1.4.1.dev135__cp312-cp312-macosx_10_13_universal2.whl → 1.5.0.dev44__cp312-cp312-macosx_10_13_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of duckdb might be problematic. Click here for more details.
- _duckdb.cpython-312-darwin.so +0 -0
- duckdb/__init__.py +435 -341
- duckdb/__init__.pyi +713 -0
- duckdb/bytes_io_wrapper.py +9 -12
- duckdb/experimental/__init__.py +1 -2
- duckdb/experimental/spark/__init__.py +4 -3
- duckdb/experimental/spark/_globals.py +8 -8
- duckdb/experimental/spark/_typing.py +9 -7
- duckdb/experimental/spark/conf.py +15 -16
- duckdb/experimental/spark/context.py +44 -60
- duckdb/experimental/spark/errors/__init__.py +35 -33
- duckdb/experimental/spark/errors/error_classes.py +1 -1
- duckdb/experimental/spark/errors/exceptions/__init__.py +1 -1
- duckdb/experimental/spark/errors/exceptions/base.py +88 -39
- duckdb/experimental/spark/errors/utils.py +16 -11
- duckdb/experimental/spark/exception.py +6 -9
- duckdb/experimental/spark/sql/__init__.py +5 -5
- duckdb/experimental/spark/sql/_typing.py +15 -8
- duckdb/experimental/spark/sql/catalog.py +20 -21
- duckdb/experimental/spark/sql/column.py +55 -48
- duckdb/experimental/spark/sql/conf.py +8 -9
- duckdb/experimental/spark/sql/dataframe.py +233 -185
- duckdb/experimental/spark/sql/functions.py +1248 -1222
- duckdb/experimental/spark/sql/group.py +52 -56
- duckdb/experimental/spark/sql/readwriter.py +94 -80
- duckdb/experimental/spark/sql/session.py +59 -64
- duckdb/experimental/spark/sql/streaming.py +10 -9
- duckdb/experimental/spark/sql/type_utils.py +65 -67
- duckdb/experimental/spark/sql/types.py +345 -309
- duckdb/experimental/spark/sql/udf.py +6 -6
- duckdb/filesystem.py +16 -26
- duckdb/functional/__init__.py +16 -12
- duckdb/functional/__init__.pyi +31 -0
- duckdb/polars_io.py +82 -124
- duckdb/query_graph/__main__.py +96 -91
- duckdb/typing/__init__.py +8 -18
- duckdb/typing/__init__.pyi +36 -0
- duckdb/udf.py +5 -10
- duckdb/value/__init__.py +0 -1
- duckdb/value/constant/__init__.py +60 -62
- duckdb/value/constant/__init__.pyi +115 -0
- duckdb-1.5.0.dev44.dist-info/METADATA +80 -0
- duckdb-1.5.0.dev44.dist-info/RECORD +47 -0
- _duckdb-stubs/__init__.pyi +0 -1443
- _duckdb-stubs/_func.pyi +0 -46
- _duckdb-stubs/_sqltypes.pyi +0 -75
- adbc_driver_duckdb/__init__.py +0 -50
- adbc_driver_duckdb/dbapi.py +0 -115
- duckdb/_dbapi_type_object.py +0 -231
- duckdb/_version.py +0 -22
- duckdb/func/__init__.py +0 -3
- duckdb/sqltypes/__init__.py +0 -63
- duckdb-1.4.1.dev135.dist-info/METADATA +0 -326
- duckdb-1.4.1.dev135.dist-info/RECORD +0 -52
- /duckdb/{py.typed → value/__init__.pyi} +0 -0
- {duckdb-1.4.1.dev135.dist-info → duckdb-1.5.0.dev44.dist-info}/WHEEL +0 -0
- {duckdb-1.4.1.dev135.dist-info → duckdb-1.5.0.dev44.dist-info}/licenses/LICENSE +0 -0
_duckdb-stubs/_func.pyi
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import typing as pytyping
|
|
2
|
-
|
|
3
|
-
__all__: list[str] = ["ARROW", "DEFAULT", "NATIVE", "SPECIAL", "FunctionNullHandling", "PythonUDFType"]
|
|
4
|
-
|
|
5
|
-
class FunctionNullHandling:
|
|
6
|
-
DEFAULT: pytyping.ClassVar[FunctionNullHandling] # value = <FunctionNullHandling.DEFAULT: 0>
|
|
7
|
-
SPECIAL: pytyping.ClassVar[FunctionNullHandling] # value = <FunctionNullHandling.SPECIAL: 1>
|
|
8
|
-
__members__: pytyping.ClassVar[
|
|
9
|
-
dict[str, FunctionNullHandling]
|
|
10
|
-
] # value = {'DEFAULT': <FunctionNullHandling.DEFAULT: 0>, 'SPECIAL': <FunctionNullHandling.SPECIAL: 1>}
|
|
11
|
-
def __eq__(self, other: object) -> bool: ...
|
|
12
|
-
def __getstate__(self) -> int: ...
|
|
13
|
-
def __hash__(self) -> int: ...
|
|
14
|
-
def __index__(self) -> int: ...
|
|
15
|
-
def __init__(self, value: pytyping.SupportsInt) -> None: ...
|
|
16
|
-
def __int__(self) -> int: ...
|
|
17
|
-
def __ne__(self, other: object) -> bool: ...
|
|
18
|
-
def __setstate__(self, state: pytyping.SupportsInt) -> None: ...
|
|
19
|
-
@property
|
|
20
|
-
def name(self) -> str: ...
|
|
21
|
-
@property
|
|
22
|
-
def value(self) -> int: ...
|
|
23
|
-
|
|
24
|
-
class PythonUDFType:
|
|
25
|
-
ARROW: pytyping.ClassVar[PythonUDFType] # value = <PythonUDFType.ARROW: 1>
|
|
26
|
-
NATIVE: pytyping.ClassVar[PythonUDFType] # value = <PythonUDFType.NATIVE: 0>
|
|
27
|
-
__members__: pytyping.ClassVar[
|
|
28
|
-
dict[str, PythonUDFType]
|
|
29
|
-
] # value = {'NATIVE': <PythonUDFType.NATIVE: 0>, 'ARROW': <PythonUDFType.ARROW: 1>}
|
|
30
|
-
def __eq__(self, other: object) -> bool: ...
|
|
31
|
-
def __getstate__(self) -> int: ...
|
|
32
|
-
def __hash__(self) -> int: ...
|
|
33
|
-
def __index__(self) -> int: ...
|
|
34
|
-
def __init__(self, value: pytyping.SupportsInt) -> None: ...
|
|
35
|
-
def __int__(self) -> int: ...
|
|
36
|
-
def __ne__(self, other: object) -> bool: ...
|
|
37
|
-
def __setstate__(self, state: pytyping.SupportsInt) -> None: ...
|
|
38
|
-
@property
|
|
39
|
-
def name(self) -> str: ...
|
|
40
|
-
@property
|
|
41
|
-
def value(self) -> int: ...
|
|
42
|
-
|
|
43
|
-
ARROW: PythonUDFType # value = <PythonUDFType.ARROW: 1>
|
|
44
|
-
DEFAULT: FunctionNullHandling # value = <FunctionNullHandling.DEFAULT: 0>
|
|
45
|
-
NATIVE: PythonUDFType # value = <PythonUDFType.NATIVE: 0>
|
|
46
|
-
SPECIAL: FunctionNullHandling # value = <FunctionNullHandling.SPECIAL: 1>
|
_duckdb-stubs/_sqltypes.pyi
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import duckdb
|
|
2
|
-
import typing as pytyping
|
|
3
|
-
|
|
4
|
-
__all__: list[str] = [
|
|
5
|
-
"BIGINT",
|
|
6
|
-
"BIT",
|
|
7
|
-
"BLOB",
|
|
8
|
-
"BOOLEAN",
|
|
9
|
-
"DATE",
|
|
10
|
-
"DOUBLE",
|
|
11
|
-
"FLOAT",
|
|
12
|
-
"HUGEINT",
|
|
13
|
-
"INTEGER",
|
|
14
|
-
"INTERVAL",
|
|
15
|
-
"SMALLINT",
|
|
16
|
-
"SQLNULL",
|
|
17
|
-
"TIME",
|
|
18
|
-
"TIMESTAMP",
|
|
19
|
-
"TIMESTAMP_MS",
|
|
20
|
-
"TIMESTAMP_NS",
|
|
21
|
-
"TIMESTAMP_S",
|
|
22
|
-
"TIMESTAMP_TZ",
|
|
23
|
-
"TIME_TZ",
|
|
24
|
-
"TINYINT",
|
|
25
|
-
"UBIGINT",
|
|
26
|
-
"UHUGEINT",
|
|
27
|
-
"UINTEGER",
|
|
28
|
-
"USMALLINT",
|
|
29
|
-
"UTINYINT",
|
|
30
|
-
"UUID",
|
|
31
|
-
"VARCHAR",
|
|
32
|
-
"DuckDBPyType",
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
class DuckDBPyType:
|
|
36
|
-
def __eq__(self, other: object) -> bool: ...
|
|
37
|
-
def __getattr__(self, name: str) -> DuckDBPyType: ...
|
|
38
|
-
def __getitem__(self, name: str) -> DuckDBPyType: ...
|
|
39
|
-
def __hash__(self) -> int: ...
|
|
40
|
-
@pytyping.overload
|
|
41
|
-
def __init__(self, type_str: str, connection: duckdb.DuckDBPyConnection) -> None: ...
|
|
42
|
-
@pytyping.overload
|
|
43
|
-
def __init__(self, obj: object) -> None: ...
|
|
44
|
-
@property
|
|
45
|
-
def children(self) -> list[tuple[str, object]]: ...
|
|
46
|
-
@property
|
|
47
|
-
def id(self) -> str: ...
|
|
48
|
-
|
|
49
|
-
BIGINT: DuckDBPyType # value = BIGINT
|
|
50
|
-
BIT: DuckDBPyType # value = BIT
|
|
51
|
-
BLOB: DuckDBPyType # value = BLOB
|
|
52
|
-
BOOLEAN: DuckDBPyType # value = BOOLEAN
|
|
53
|
-
DATE: DuckDBPyType # value = DATE
|
|
54
|
-
DOUBLE: DuckDBPyType # value = DOUBLE
|
|
55
|
-
FLOAT: DuckDBPyType # value = FLOAT
|
|
56
|
-
HUGEINT: DuckDBPyType # value = HUGEINT
|
|
57
|
-
INTEGER: DuckDBPyType # value = INTEGER
|
|
58
|
-
INTERVAL: DuckDBPyType # value = INTERVAL
|
|
59
|
-
SMALLINT: DuckDBPyType # value = SMALLINT
|
|
60
|
-
SQLNULL: DuckDBPyType # value = "NULL"
|
|
61
|
-
TIME: DuckDBPyType # value = TIME
|
|
62
|
-
TIMESTAMP: DuckDBPyType # value = TIMESTAMP
|
|
63
|
-
TIMESTAMP_MS: DuckDBPyType # value = TIMESTAMP_MS
|
|
64
|
-
TIMESTAMP_NS: DuckDBPyType # value = TIMESTAMP_NS
|
|
65
|
-
TIMESTAMP_S: DuckDBPyType # value = TIMESTAMP_S
|
|
66
|
-
TIMESTAMP_TZ: DuckDBPyType # value = TIMESTAMP WITH TIME ZONE
|
|
67
|
-
TIME_TZ: DuckDBPyType # value = TIME WITH TIME ZONE
|
|
68
|
-
TINYINT: DuckDBPyType # value = TINYINT
|
|
69
|
-
UBIGINT: DuckDBPyType # value = UBIGINT
|
|
70
|
-
UHUGEINT: DuckDBPyType # value = UHUGEINT
|
|
71
|
-
UINTEGER: DuckDBPyType # value = UINTEGER
|
|
72
|
-
USMALLINT: DuckDBPyType # value = USMALLINT
|
|
73
|
-
UTINYINT: DuckDBPyType # value = UTINYINT
|
|
74
|
-
UUID: DuckDBPyType # value = UUID
|
|
75
|
-
VARCHAR: DuckDBPyType # value = VARCHAR
|
adbc_driver_duckdb/__init__.py
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
|
3
|
-
# distributed with this work for additional information
|
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
|
6
|
-
# "License"); you may not use this file except in compliance
|
|
7
|
-
# with the License. You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
|
12
|
-
# software distributed under the License is distributed on an
|
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
# KIND, either express or implied. See the License for the
|
|
15
|
-
# specific language governing permissions and limitations
|
|
16
|
-
# under the License.
|
|
17
|
-
|
|
18
|
-
"""Low-level ADBC bindings for the DuckDB driver."""
|
|
19
|
-
|
|
20
|
-
import enum
|
|
21
|
-
import functools
|
|
22
|
-
import importlib
|
|
23
|
-
import typing
|
|
24
|
-
|
|
25
|
-
import adbc_driver_manager
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class StatementOptions(enum.Enum):
|
|
29
|
-
"""Statement options specific to the DuckDB driver."""
|
|
30
|
-
|
|
31
|
-
#: The number of rows per batch. Defaults to 2048.
|
|
32
|
-
BATCH_ROWS = "adbc.duckdb.query.batch_rows"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def connect(path: typing.Optional[str] = None) -> adbc_driver_manager.AdbcDatabase:
|
|
36
|
-
"""Create a low level ADBC connection to DuckDB."""
|
|
37
|
-
if path is None:
|
|
38
|
-
return adbc_driver_manager.AdbcDatabase(driver=driver_path(), entrypoint="duckdb_adbc_init")
|
|
39
|
-
return adbc_driver_manager.AdbcDatabase(driver=driver_path(), entrypoint="duckdb_adbc_init", path=path)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@functools.cache
|
|
43
|
-
def driver_path() -> str:
|
|
44
|
-
"""Get the path to the DuckDB ADBC driver."""
|
|
45
|
-
duckdb_module_spec = importlib.util.find_spec("_duckdb")
|
|
46
|
-
if duckdb_module_spec is None:
|
|
47
|
-
msg = "Could not find duckdb shared library. Did you pip install duckdb?"
|
|
48
|
-
raise ImportError(msg)
|
|
49
|
-
print(f"Found duckdb shared library at {duckdb_module_spec.origin}")
|
|
50
|
-
return duckdb_module_spec.origin
|
adbc_driver_duckdb/dbapi.py
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
|
3
|
-
# distributed with this work for additional information
|
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
|
6
|
-
# "License"); you may not use this file except in compliance
|
|
7
|
-
# with the License. You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
|
12
|
-
# software distributed under the License is distributed on an
|
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
# KIND, either express or implied. See the License for the
|
|
15
|
-
# specific language governing permissions and limitations
|
|
16
|
-
# under the License.
|
|
17
|
-
|
|
18
|
-
"""DBAPI 2.0-compatible facade for the ADBC DuckDB driver."""
|
|
19
|
-
|
|
20
|
-
import typing
|
|
21
|
-
|
|
22
|
-
import adbc_driver_manager
|
|
23
|
-
import adbc_driver_manager.dbapi
|
|
24
|
-
|
|
25
|
-
import adbc_driver_duckdb
|
|
26
|
-
|
|
27
|
-
__all__ = [
|
|
28
|
-
"BINARY",
|
|
29
|
-
"DATETIME",
|
|
30
|
-
"NUMBER",
|
|
31
|
-
"ROWID",
|
|
32
|
-
"STRING",
|
|
33
|
-
"Connection",
|
|
34
|
-
"Cursor",
|
|
35
|
-
"DataError",
|
|
36
|
-
"DatabaseError",
|
|
37
|
-
"Date",
|
|
38
|
-
"DateFromTicks",
|
|
39
|
-
"Error",
|
|
40
|
-
"IntegrityError",
|
|
41
|
-
"InterfaceError",
|
|
42
|
-
"InternalError",
|
|
43
|
-
"NotSupportedError",
|
|
44
|
-
"OperationalError",
|
|
45
|
-
"ProgrammingError",
|
|
46
|
-
"Time",
|
|
47
|
-
"TimeFromTicks",
|
|
48
|
-
"Timestamp",
|
|
49
|
-
"TimestampFromTicks",
|
|
50
|
-
"Warning",
|
|
51
|
-
"apilevel",
|
|
52
|
-
"connect",
|
|
53
|
-
"paramstyle",
|
|
54
|
-
"threadsafety",
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
-
# ----------------------------------------------------------
|
|
58
|
-
# Globals
|
|
59
|
-
|
|
60
|
-
apilevel = adbc_driver_manager.dbapi.apilevel
|
|
61
|
-
threadsafety = adbc_driver_manager.dbapi.threadsafety
|
|
62
|
-
paramstyle = "qmark"
|
|
63
|
-
|
|
64
|
-
Warning = adbc_driver_manager.dbapi.Warning
|
|
65
|
-
Error = adbc_driver_manager.dbapi.Error
|
|
66
|
-
InterfaceError = adbc_driver_manager.dbapi.InterfaceError
|
|
67
|
-
DatabaseError = adbc_driver_manager.dbapi.DatabaseError
|
|
68
|
-
DataError = adbc_driver_manager.dbapi.DataError
|
|
69
|
-
OperationalError = adbc_driver_manager.dbapi.OperationalError
|
|
70
|
-
IntegrityError = adbc_driver_manager.dbapi.IntegrityError
|
|
71
|
-
InternalError = adbc_driver_manager.dbapi.InternalError
|
|
72
|
-
ProgrammingError = adbc_driver_manager.dbapi.ProgrammingError
|
|
73
|
-
NotSupportedError = adbc_driver_manager.dbapi.NotSupportedError
|
|
74
|
-
|
|
75
|
-
# ----------------------------------------------------------
|
|
76
|
-
# Types
|
|
77
|
-
|
|
78
|
-
Date = adbc_driver_manager.dbapi.Date
|
|
79
|
-
Time = adbc_driver_manager.dbapi.Time
|
|
80
|
-
Timestamp = adbc_driver_manager.dbapi.Timestamp
|
|
81
|
-
DateFromTicks = adbc_driver_manager.dbapi.DateFromTicks
|
|
82
|
-
TimeFromTicks = adbc_driver_manager.dbapi.TimeFromTicks
|
|
83
|
-
TimestampFromTicks = adbc_driver_manager.dbapi.TimestampFromTicks
|
|
84
|
-
STRING = adbc_driver_manager.dbapi.STRING
|
|
85
|
-
BINARY = adbc_driver_manager.dbapi.BINARY
|
|
86
|
-
NUMBER = adbc_driver_manager.dbapi.NUMBER
|
|
87
|
-
DATETIME = adbc_driver_manager.dbapi.DATETIME
|
|
88
|
-
ROWID = adbc_driver_manager.dbapi.ROWID
|
|
89
|
-
|
|
90
|
-
# ----------------------------------------------------------
|
|
91
|
-
# Functions
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def connect(path: typing.Optional[str] = None, **kwargs) -> "Connection":
|
|
95
|
-
"""Connect to DuckDB via ADBC."""
|
|
96
|
-
db = None
|
|
97
|
-
conn = None
|
|
98
|
-
|
|
99
|
-
try:
|
|
100
|
-
db = adbc_driver_duckdb.connect(path)
|
|
101
|
-
conn = adbc_driver_manager.AdbcConnection(db)
|
|
102
|
-
return adbc_driver_manager.dbapi.Connection(db, conn, **kwargs)
|
|
103
|
-
except Exception:
|
|
104
|
-
if conn:
|
|
105
|
-
conn.close()
|
|
106
|
-
if db:
|
|
107
|
-
db.close()
|
|
108
|
-
raise
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
# ----------------------------------------------------------
|
|
112
|
-
# Classes
|
|
113
|
-
|
|
114
|
-
Connection = adbc_driver_manager.dbapi.Connection
|
|
115
|
-
Cursor = adbc_driver_manager.dbapi.Cursor
|
duckdb/_dbapi_type_object.py
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
"""DuckDB DB API 2.0 Type Objects Module.
|
|
2
|
-
|
|
3
|
-
This module provides DB API 2.0 compliant type objects for DuckDB, allowing applications
|
|
4
|
-
to check column types returned by queries against standard database API categories.
|
|
5
|
-
|
|
6
|
-
Example:
|
|
7
|
-
>>> import duckdb
|
|
8
|
-
>>>
|
|
9
|
-
>>> conn = duckdb.connect()
|
|
10
|
-
>>> cursor = conn.cursor()
|
|
11
|
-
>>> cursor.execute("SELECT 'hello' as text_col, 42 as num_col, CURRENT_DATE as date_col")
|
|
12
|
-
>>>
|
|
13
|
-
>>> # Check column types using DB API type objects
|
|
14
|
-
>>> for i, desc in enumerate(cursor.description):
|
|
15
|
-
>>> col_name, col_type = desc[0], desc[1]
|
|
16
|
-
>>> if col_type == duckdb.STRING:
|
|
17
|
-
>>> print(f"{col_name} is a string type")
|
|
18
|
-
>>> elif col_type == duckdb.NUMBER:
|
|
19
|
-
>>> print(f"{col_name} is a numeric type")
|
|
20
|
-
>>> elif col_type == duckdb.DATETIME:
|
|
21
|
-
>>> print(f"{col_name} is a date/time type")
|
|
22
|
-
|
|
23
|
-
See Also:
|
|
24
|
-
- PEP 249: https://peps.python.org/pep-0249/
|
|
25
|
-
- DuckDB Type System: https://duckdb.org/docs/sql/data_types/overview
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
from duckdb import sqltypes
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class DBAPITypeObject:
|
|
32
|
-
"""DB API 2.0 type object for categorizing database column types.
|
|
33
|
-
|
|
34
|
-
This class implements the type objects defined in PEP 249 (DB API 2.0).
|
|
35
|
-
It allows checking whether a specific DuckDB type belongs to a broader
|
|
36
|
-
category like STRING, NUMBER, DATETIME, etc.
|
|
37
|
-
|
|
38
|
-
The type object supports equality comparison with DuckDBPyType instances,
|
|
39
|
-
returning True if the type belongs to this category.
|
|
40
|
-
|
|
41
|
-
Args:
|
|
42
|
-
types: A list of DuckDBPyType instances that belong to this type category.
|
|
43
|
-
|
|
44
|
-
Example:
|
|
45
|
-
>>> string_types = DBAPITypeObject([sqltypes.VARCHAR, sqltypes.CHAR])
|
|
46
|
-
>>> result = sqltypes.VARCHAR == string_types # True
|
|
47
|
-
>>> result = sqltypes.INTEGER == string_types # False
|
|
48
|
-
|
|
49
|
-
Note:
|
|
50
|
-
This follows the DB API 2.0 specification where type objects are compared
|
|
51
|
-
using equality operators rather than isinstance() checks.
|
|
52
|
-
"""
|
|
53
|
-
|
|
54
|
-
def __init__(self, types: list[sqltypes.DuckDBPyType]) -> None:
|
|
55
|
-
"""Initialize a DB API type object.
|
|
56
|
-
|
|
57
|
-
Args:
|
|
58
|
-
types: List of DuckDB types that belong to this category.
|
|
59
|
-
"""
|
|
60
|
-
self.types = types
|
|
61
|
-
|
|
62
|
-
def __eq__(self, other: object) -> bool:
|
|
63
|
-
"""Check if a DuckDB type belongs to this type category.
|
|
64
|
-
|
|
65
|
-
This method implements the DB API 2.0 type checking mechanism.
|
|
66
|
-
It returns True if the other object is a DuckDBPyType that
|
|
67
|
-
is contained in this type category.
|
|
68
|
-
|
|
69
|
-
Args:
|
|
70
|
-
other: The object to compare, typically a DuckDBPyType instance.
|
|
71
|
-
|
|
72
|
-
Returns:
|
|
73
|
-
True if other is a DuckDBPyType in this category, False otherwise.
|
|
74
|
-
|
|
75
|
-
Example:
|
|
76
|
-
>>> NUMBER == sqltypes.INTEGER # True
|
|
77
|
-
>>> NUMBER == sqltypes.VARCHAR # False
|
|
78
|
-
"""
|
|
79
|
-
if isinstance(other, sqltypes.DuckDBPyType):
|
|
80
|
-
return other in self.types
|
|
81
|
-
return False
|
|
82
|
-
|
|
83
|
-
def __repr__(self) -> str:
|
|
84
|
-
"""Return a string representation of this type object.
|
|
85
|
-
|
|
86
|
-
Returns:
|
|
87
|
-
A string showing the type object and its contained DuckDB types.
|
|
88
|
-
|
|
89
|
-
Example:
|
|
90
|
-
>>> repr(STRING)
|
|
91
|
-
'<DBAPITypeObject [VARCHAR]>'
|
|
92
|
-
"""
|
|
93
|
-
return f"<DBAPITypeObject [{','.join(str(x) for x in self.types)}]>"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
# Define the standard DB API 2.0 type objects for DuckDB
|
|
97
|
-
|
|
98
|
-
STRING = DBAPITypeObject([sqltypes.VARCHAR])
|
|
99
|
-
"""
|
|
100
|
-
STRING type object for text-based database columns.
|
|
101
|
-
|
|
102
|
-
This type object represents all string/text types in DuckDB. Currently includes:
|
|
103
|
-
- VARCHAR: Variable-length character strings
|
|
104
|
-
|
|
105
|
-
Use this to check if a column contains textual data that should be handled
|
|
106
|
-
as Python strings.
|
|
107
|
-
|
|
108
|
-
DB API 2.0 Reference:
|
|
109
|
-
https://peps.python.org/pep-0249/#string
|
|
110
|
-
|
|
111
|
-
Example:
|
|
112
|
-
>>> cursor.description[0][1] == STRING # Check if first column is text
|
|
113
|
-
"""
|
|
114
|
-
|
|
115
|
-
NUMBER = DBAPITypeObject(
|
|
116
|
-
[
|
|
117
|
-
sqltypes.TINYINT,
|
|
118
|
-
sqltypes.UTINYINT,
|
|
119
|
-
sqltypes.SMALLINT,
|
|
120
|
-
sqltypes.USMALLINT,
|
|
121
|
-
sqltypes.INTEGER,
|
|
122
|
-
sqltypes.UINTEGER,
|
|
123
|
-
sqltypes.BIGINT,
|
|
124
|
-
sqltypes.UBIGINT,
|
|
125
|
-
sqltypes.HUGEINT,
|
|
126
|
-
sqltypes.UHUGEINT,
|
|
127
|
-
sqltypes.DuckDBPyType("BIGNUM"),
|
|
128
|
-
sqltypes.DuckDBPyType("DECIMAL"),
|
|
129
|
-
sqltypes.FLOAT,
|
|
130
|
-
sqltypes.DOUBLE,
|
|
131
|
-
]
|
|
132
|
-
)
|
|
133
|
-
"""
|
|
134
|
-
NUMBER type object for numeric database columns.
|
|
135
|
-
|
|
136
|
-
This type object represents all numeric types in DuckDB, including:
|
|
137
|
-
|
|
138
|
-
Integer Types:
|
|
139
|
-
- TINYINT, UTINYINT: 8-bit signed/unsigned integers
|
|
140
|
-
- SMALLINT, USMALLINT: 16-bit signed/unsigned integers
|
|
141
|
-
- INTEGER, UINTEGER: 32-bit signed/unsigned integers
|
|
142
|
-
- BIGINT, UBIGINT: 64-bit signed/unsigned integers
|
|
143
|
-
- HUGEINT, UHUGEINT: 128-bit signed/unsigned integers
|
|
144
|
-
|
|
145
|
-
Decimal Types:
|
|
146
|
-
- BIGNUM: Arbitrary precision integers
|
|
147
|
-
- DECIMAL: Fixed-point decimal numbers
|
|
148
|
-
|
|
149
|
-
Floating Point Types:
|
|
150
|
-
- FLOAT: 32-bit floating point
|
|
151
|
-
- DOUBLE: 64-bit floating point
|
|
152
|
-
|
|
153
|
-
Use this to check if a column contains numeric data that should be handled
|
|
154
|
-
as Python int, float, or Decimal objects.
|
|
155
|
-
|
|
156
|
-
DB API 2.0 Reference:
|
|
157
|
-
https://peps.python.org/pep-0249/#number
|
|
158
|
-
|
|
159
|
-
Example:
|
|
160
|
-
>>> cursor.description[1][1] == NUMBER # Check if second column is numeric
|
|
161
|
-
"""
|
|
162
|
-
|
|
163
|
-
DATETIME = DBAPITypeObject(
|
|
164
|
-
[
|
|
165
|
-
sqltypes.DATE,
|
|
166
|
-
sqltypes.TIME,
|
|
167
|
-
sqltypes.TIME_TZ,
|
|
168
|
-
sqltypes.TIMESTAMP,
|
|
169
|
-
sqltypes.TIMESTAMP_TZ,
|
|
170
|
-
sqltypes.TIMESTAMP_NS,
|
|
171
|
-
sqltypes.TIMESTAMP_MS,
|
|
172
|
-
sqltypes.TIMESTAMP_S,
|
|
173
|
-
]
|
|
174
|
-
)
|
|
175
|
-
"""
|
|
176
|
-
DATETIME type object for date and time database columns.
|
|
177
|
-
|
|
178
|
-
This type object represents all date/time types in DuckDB, including:
|
|
179
|
-
|
|
180
|
-
Date Types:
|
|
181
|
-
- DATE: Calendar dates (year, month, day)
|
|
182
|
-
|
|
183
|
-
Time Types:
|
|
184
|
-
- TIME: Time of day without timezone
|
|
185
|
-
- TIME_TZ: Time of day with timezone
|
|
186
|
-
|
|
187
|
-
Timestamp Types:
|
|
188
|
-
- TIMESTAMP: Date and time without timezone (microsecond precision)
|
|
189
|
-
- TIMESTAMP_TZ: Date and time with timezone
|
|
190
|
-
- TIMESTAMP_NS: Nanosecond precision timestamps
|
|
191
|
-
- TIMESTAMP_MS: Millisecond precision timestamps
|
|
192
|
-
- TIMESTAMP_S: Second precision timestamps
|
|
193
|
-
|
|
194
|
-
Use this to check if a column contains temporal data that should be handled
|
|
195
|
-
as Python datetime, date, or time objects.
|
|
196
|
-
|
|
197
|
-
DB API 2.0 Reference:
|
|
198
|
-
https://peps.python.org/pep-0249/#datetime
|
|
199
|
-
|
|
200
|
-
Example:
|
|
201
|
-
>>> cursor.description[2][1] == DATETIME # Check if third column is date/time
|
|
202
|
-
"""
|
|
203
|
-
|
|
204
|
-
BINARY = DBAPITypeObject([sqltypes.BLOB])
|
|
205
|
-
"""
|
|
206
|
-
BINARY type object for binary data database columns.
|
|
207
|
-
|
|
208
|
-
This type object represents binary data types in DuckDB:
|
|
209
|
-
- BLOB: Binary Large Objects for storing arbitrary binary data
|
|
210
|
-
|
|
211
|
-
Use this to check if a column contains binary data that should be handled
|
|
212
|
-
as Python bytes objects.
|
|
213
|
-
|
|
214
|
-
DB API 2.0 Reference:
|
|
215
|
-
https://peps.python.org/pep-0249/#binary
|
|
216
|
-
|
|
217
|
-
Example:
|
|
218
|
-
>>> cursor.description[3][1] == BINARY # Check if fourth column is binary
|
|
219
|
-
"""
|
|
220
|
-
|
|
221
|
-
ROWID = None
|
|
222
|
-
"""
|
|
223
|
-
ROWID type object for row identifier columns.
|
|
224
|
-
|
|
225
|
-
DB API 2.0 Reference:
|
|
226
|
-
https://peps.python.org/pep-0249/#rowid
|
|
227
|
-
|
|
228
|
-
Note:
|
|
229
|
-
This will always be None for DuckDB connections. Applications should not
|
|
230
|
-
rely on ROWID functionality when using DuckDB.
|
|
231
|
-
"""
|
duckdb/_version.py
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# ----------------------------------------------------------------------
|
|
2
|
-
# Version API
|
|
3
|
-
#
|
|
4
|
-
# We provide three symbols:
|
|
5
|
-
# - duckdb.__version__: The version of this package
|
|
6
|
-
# - duckdb.__duckdb_version__: The version of duckdb that is bundled
|
|
7
|
-
# - duckdb.version(): A human-readable version string containing both of the above
|
|
8
|
-
# ----------------------------------------------------------------------
|
|
9
|
-
from importlib.metadata import version as _dist_version
|
|
10
|
-
|
|
11
|
-
import _duckdb
|
|
12
|
-
|
|
13
|
-
__version__: str = _dist_version("duckdb")
|
|
14
|
-
"""Version of the DuckDB Python Package."""
|
|
15
|
-
|
|
16
|
-
__duckdb_version__: str = _duckdb.__version__
|
|
17
|
-
"""Version of DuckDB that is bundled."""
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def version() -> str:
|
|
21
|
-
"""Human-friendly formatted version string of both the distribution package and the bundled DuckDB engine."""
|
|
22
|
-
return f"{__version__} (with duckdb {_duckdb.__version__})"
|
duckdb/func/__init__.py
DELETED
duckdb/sqltypes/__init__.py
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"""DuckDB's SQL types."""
|
|
2
|
-
|
|
3
|
-
from _duckdb._sqltypes import (
|
|
4
|
-
BIGINT,
|
|
5
|
-
BIT,
|
|
6
|
-
BLOB,
|
|
7
|
-
BOOLEAN,
|
|
8
|
-
DATE,
|
|
9
|
-
DOUBLE,
|
|
10
|
-
FLOAT,
|
|
11
|
-
HUGEINT,
|
|
12
|
-
INTEGER,
|
|
13
|
-
INTERVAL,
|
|
14
|
-
SMALLINT,
|
|
15
|
-
SQLNULL,
|
|
16
|
-
TIME,
|
|
17
|
-
TIME_TZ,
|
|
18
|
-
TIMESTAMP,
|
|
19
|
-
TIMESTAMP_MS,
|
|
20
|
-
TIMESTAMP_NS,
|
|
21
|
-
TIMESTAMP_S,
|
|
22
|
-
TIMESTAMP_TZ,
|
|
23
|
-
TINYINT,
|
|
24
|
-
UBIGINT,
|
|
25
|
-
UHUGEINT,
|
|
26
|
-
UINTEGER,
|
|
27
|
-
USMALLINT,
|
|
28
|
-
UTINYINT,
|
|
29
|
-
UUID,
|
|
30
|
-
VARCHAR,
|
|
31
|
-
DuckDBPyType,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
__all__ = [
|
|
35
|
-
"BIGINT",
|
|
36
|
-
"BIT",
|
|
37
|
-
"BLOB",
|
|
38
|
-
"BOOLEAN",
|
|
39
|
-
"DATE",
|
|
40
|
-
"DOUBLE",
|
|
41
|
-
"FLOAT",
|
|
42
|
-
"HUGEINT",
|
|
43
|
-
"INTEGER",
|
|
44
|
-
"INTERVAL",
|
|
45
|
-
"SMALLINT",
|
|
46
|
-
"SQLNULL",
|
|
47
|
-
"TIME",
|
|
48
|
-
"TIMESTAMP",
|
|
49
|
-
"TIMESTAMP_MS",
|
|
50
|
-
"TIMESTAMP_NS",
|
|
51
|
-
"TIMESTAMP_S",
|
|
52
|
-
"TIMESTAMP_TZ",
|
|
53
|
-
"TIME_TZ",
|
|
54
|
-
"TINYINT",
|
|
55
|
-
"UBIGINT",
|
|
56
|
-
"UHUGEINT",
|
|
57
|
-
"UINTEGER",
|
|
58
|
-
"USMALLINT",
|
|
59
|
-
"UTINYINT",
|
|
60
|
-
"UUID",
|
|
61
|
-
"VARCHAR",
|
|
62
|
-
"DuckDBPyType",
|
|
63
|
-
]
|