2525 - DuckDB Type System: https://duckdb.org/docs/sql/data_types/overview
2626"""
2727
28- import duckdb . typing as duckdb_typing
28+ from duckdb import sqltypes
2929
3030
3131class DBAPITypeObject :
@@ -42,16 +42,16 @@ class DBAPITypeObject:
4242 types: A list of DuckDBPyType instances that belong to this type category.
4343
4444 Example:
45- >>> string_types = DBAPITypeObject([duckdb_typing .VARCHAR, duckdb_typing .CHAR])
46- >>> result = duckdb_typing .VARCHAR == string_types # True
47- >>> result = duckdb_typing .INTEGER == string_types # False
45+ >>> string_types = DBAPITypeObject([sqltypes .VARCHAR, sqltypes .CHAR])
46+ >>> result = sqltypes .VARCHAR == string_types # True
47+ >>> result = sqltypes .INTEGER == string_types # False
4848
4949 Note:
5050 This follows the DB API 2.0 specification where type objects are compared
5151 using equality operators rather than isinstance() checks.
5252 """
5353
54- def __init__ (self , types : list [duckdb_typing .DuckDBPyType ]) -> None :
54+ def __init__ (self , types : list [sqltypes .DuckDBPyType ]) -> None :
5555 """Initialize a DB API type object.
5656
5757 Args:
@@ -73,10 +73,10 @@ def __eq__(self, other: object) -> bool:
7373 True if other is a DuckDBPyType in this category, False otherwise.
7474
7575 Example:
76- >>> NUMBER == duckdb_typing .INTEGER # True
77- >>> NUMBER == duckdb_typing .VARCHAR # False
76+ >>> NUMBER == sqltypes .INTEGER # True
77+ >>> NUMBER == sqltypes .VARCHAR # False
7878 """
79- if isinstance (other , duckdb_typing .DuckDBPyType ):
79+ if isinstance (other , sqltypes .DuckDBPyType ):
8080 return other in self .types
8181 return False
8282
@@ -95,7 +95,7 @@ def __repr__(self) -> str:
9595
9696# Define the standard DB API 2.0 type objects for DuckDB
9797
98- STRING = DBAPITypeObject ([duckdb_typing .VARCHAR ])
98+ STRING = DBAPITypeObject ([sqltypes .VARCHAR ])
9999"""
100100STRING type object for text-based database columns.
101101
@@ -114,20 +114,20 @@ def __repr__(self) -> str:
114114
115115NUMBER = DBAPITypeObject (
116116 [
117- duckdb_typing .TINYINT ,
118- duckdb_typing .UTINYINT ,
119- duckdb_typing .SMALLINT ,
120- duckdb_typing .USMALLINT ,
121- duckdb_typing .INTEGER ,
122- duckdb_typing .UINTEGER ,
123- duckdb_typing .BIGINT ,
124- duckdb_typing .UBIGINT ,
125- duckdb_typing .HUGEINT ,
126- duckdb_typing .UHUGEINT ,
127- duckdb_typing .DuckDBPyType ("BIGNUM" ),
128- duckdb_typing .DuckDBPyType ("DECIMAL" ),
129- duckdb_typing .FLOAT ,
130- duckdb_typing .DOUBLE ,
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 ,
131131 ]
132132)
133133"""
@@ -162,14 +162,14 @@ def __repr__(self) -> str:
162162
163163DATETIME = DBAPITypeObject (
164164 [
165- duckdb_typing .DATE ,
166- duckdb_typing .TIME ,
167- duckdb_typing .TIME_TZ ,
168- duckdb_typing .TIMESTAMP ,
169- duckdb_typing .TIMESTAMP_TZ ,
170- duckdb_typing .TIMESTAMP_NS ,
171- duckdb_typing .TIMESTAMP_MS ,
172- duckdb_typing .TIMESTAMP_S ,
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 ,
173173 ]
174174)
175175"""
@@ -201,7 +201,7 @@ def __repr__(self) -> str:
201201 >>> cursor.description[2][1] == DATETIME # Check if third column is date/time
202202"""
203203
204- BINARY = DBAPITypeObject ([duckdb_typing .BLOB ])
204+ BINARY = DBAPITypeObject ([sqltypes .BLOB ])
205205"""
206206BINARY type object for binary data database columns.
207207
0 commit comments