@@ -12,97 +12,134 @@ For more information about YDB data types, see the `YDB Type System Documentatio
1212Type Mapping Summary
1313--------------------
1414
15- The following table shows the complete mapping between YDB native types, SQLAlchemy types, and Python types:
15+ The following table shows the complete mapping between YDB native types, YDB SQLAlchemy types, standard SQLAlchemy types, and Python types:
1616
1717.. list-table :: YDB Type System Reference
1818 :header-rows: 1
19- :widths: 20 25 20 35
19+ :widths: 15 20 20 15 30
2020
2121 * - YDB Native Type
22- - SQLAlchemy Type
22+ - YDB SA Type
23+ - SA Type
2324 - Python Type
2425 - Notes
2526 * - ``Bool ``
26- - ``BOOLEAN ``
27+ -
28+ - ``Boolean ``
2729 - ``bool ``
2830 -
2931 * - ``Int8 ``
32+ - :class: `~ydb_sqlalchemy.sqlalchemy.types.Int8 `
3033 -
3134 - ``int ``
3235 - -2^7 to 2^7-1
3336 * - ``Int16 ``
37+ - :class: `~ydb_sqlalchemy.sqlalchemy.types.Int16 `
3438 -
3539 - ``int ``
3640 - -2^15 to 2^15-1
3741 * - ``Int32 ``
42+ - :class: `~ydb_sqlalchemy.sqlalchemy.types.Int32 `
3843 -
3944 - ``int ``
4045 - -2^31 to 2^31-1
4146 * - ``Int64 ``
42- - ``INTEGER ``
47+ - :class: `~ydb_sqlalchemy.sqlalchemy.types.Int64 `
48+ - ``Integer ``
4349 - ``int ``
44- - -2^63 to 2^63-1
50+ - -2^63 to 2^63-1, default integer type
4551 * - ``Uint8 ``
52+ - :class: `~ydb_sqlalchemy.sqlalchemy.types.UInt8 `
4653 -
4754 - ``int ``
4855 - 0 to 2^8-1
4956 * - ``Uint16 ``
57+ - :class: `~ydb_sqlalchemy.sqlalchemy.types.UInt16 `
5058 -
5159 - ``int ``
5260 - 0 to 2^16-1
5361 * - ``Uint32 ``
62+ - :class: `~ydb_sqlalchemy.sqlalchemy.types.UInt32 `
5463 -
5564 - ``int ``
5665 - 0 to 2^32-1
5766 * - ``Uint64 ``
67+ - :class: `~ydb_sqlalchemy.sqlalchemy.types.UInt64 `
5868 -
5969 - ``int ``
6070 - 0 to 2^64-1
6171 * - ``Float ``
62- - ``FLOAT ``
72+ -
73+ - ``Float ``
6374 - ``float ``
6475 -
6576 * - ``Double ``
77+ -
6678 - ``Double ``
6779 - ``float ``
6880 - Available in SQLAlchemy 2.0+
6981 * - ``Decimal(p,s) ``
70- - ``DECIMAL `` / ``NUMERIC ``
82+ - :class: `~ydb_sqlalchemy.sqlalchemy.types.Decimal `
83+ - ``DECIMAL ``
7184 - ``decimal.Decimal ``
7285 -
7386 * - ``String ``
74- - ``BINARY `` / ``BLOB ``
75- - ``str `` / ``bytes ``
87+ -
88+ - ``BINARY ``
89+ - ``bytes ``
7690 -
7791 * - ``Utf8 ``
78- - ``CHAR `` / ``VARCHAR `` / ``TEXT `` / ``NVARCHAR ``
92+ -
93+ - ``String `` / ``Text ``
7994 - ``str ``
8095 -
8196 * - ``Date ``
97+ - :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlDate `
8298 - ``Date ``
8399 - ``datetime.date ``
84100 -
101+ * - ``Date32 ``
102+ - :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlDate32 `
103+ -
104+ - ``datetime.date ``
105+ - Extended date range support
85106 * - ``Datetime ``
107+ - :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlDateTime `
86108 - ``DATETIME ``
87109 - ``datetime.datetime ``
88110 -
111+ * - ``Datetime64 ``
112+ - :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlDateTime64 `
113+ -
114+ - ``datetime.datetime ``
115+ - Extended datetime range
89116 * - ``Timestamp ``
117+ - :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlTimestamp `
90118 - ``TIMESTAMP ``
91119 - ``datetime.datetime ``
92120 -
121+ * - ``Timestamp64 ``
122+ - :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlTimestamp64 `
123+ -
124+ - ``datetime.datetime ``
125+ - Extended timestamp range
93126 * - ``Json ``
127+ - :class: `~ydb_sqlalchemy.sqlalchemy.json.YqlJSON `
94128 - ``JSON ``
95129 - ``dict `` / ``list ``
96130 -
97131 * - ``List<T> ``
132+ - :class: `~ydb_sqlalchemy.sqlalchemy.types.ListType `
98133 - ``ARRAY ``
99134 - ``list ``
100135 -
101136 * - ``Struct<...> ``
137+ - :class: `~ydb_sqlalchemy.sqlalchemy.types.StructType `
102138 -
103139 - ``dict ``
104140 -
105141 * - ``Optional<T> ``
142+ -
106143 - ``nullable=True ``
107144 - ``None `` + base type
108145 -
@@ -145,6 +182,10 @@ YDB provides specific integer types with defined bit widths:
145182 byte_value = Column(UInt8) # Unsigned 8-bit integer (0-255)
146183 counter = Column(UInt32) # Unsigned 32-bit integer
147184
185+ For detailed API reference, see:
186+ :class: `~ydb_sqlalchemy.sqlalchemy.types.Int8 `, :class: `~ydb_sqlalchemy.sqlalchemy.types.Int16 `, :class: `~ydb_sqlalchemy.sqlalchemy.types.Int32 `, :class: `~ydb_sqlalchemy.sqlalchemy.types.Int64 `,
187+ :class: `~ydb_sqlalchemy.sqlalchemy.types.UInt8 `, :class: `~ydb_sqlalchemy.sqlalchemy.types.UInt16 `, :class: `~ydb_sqlalchemy.sqlalchemy.types.UInt32 `, :class: `~ydb_sqlalchemy.sqlalchemy.types.UInt64 `.
188+
148189Decimal Type
149190------------
150191
@@ -176,14 +217,19 @@ YDB supports high-precision decimal numbers:
176217 percentage = 99.99
177218 ))
178219
220+ For detailed API reference, see: :class: `~ydb_sqlalchemy.sqlalchemy.types.Decimal `.
221+
179222Date and Time Types
180223-------------------
181224
182225YDB provides several date and time types:
183226
184227.. code-block :: python
185228
186- from ydb_sqlalchemy.sqlalchemy.types import YqlDate, YqlDateTime, YqlTimestamp
229+ from ydb_sqlalchemy.sqlalchemy.types import (
230+ YqlDate, YqlDateTime, YqlTimestamp,
231+ YqlDate32, YqlDateTime64, YqlTimestamp64
232+ )
187233 from sqlalchemy import DateTime
188234 import datetime
189235
@@ -192,15 +238,24 @@ YDB provides several date and time types:
192238
193239 id = Column(UInt64, primary_key = True )
194240
195- # Date only (YYYY-MM-DD)
241+ # Date only (YYYY-MM-DD) - standard range
196242 event_date = Column(YqlDate)
197243
198- # DateTime with timezone support
244+ # Date32 - extended date range support
245+ extended_date = Column(YqlDate32)
246+
247+ # DateTime with timezone support - standard range
199248 created_at = Column(YqlDateTime(timezone = True ))
200249
201- # Timestamp (high precision)
250+ # DateTime64 - extended range
251+ precise_datetime = Column(YqlDateTime64(timezone = True ))
252+
253+ # Timestamp (high precision) - standard range
202254 precise_time = Column(YqlTimestamp)
203255
256+ # Timestamp64 - extended range with microsecond precision
257+ extended_timestamp = Column(YqlTimestamp64)
258+
204259 # Standard SQLAlchemy DateTime also works
205260 updated_at = Column(DateTime)
206261
@@ -211,7 +266,14 @@ YDB provides several date and time types:
211266 session.add(EventLog(
212267 id = 1 ,
213268 event_date = today,
269+ extended_date = today,
214270 created_at = now,
271+ precise_datetime = now,
215272 precise_time = now,
273+ extended_timestamp = now,
216274 updated_at = now
217275 ))
276+
277+ For detailed API reference, see:
278+ :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlDate `, :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlDateTime `, :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlTimestamp `,
279+ :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlDate32 `, :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlDateTime64 `, :class: `~ydb_sqlalchemy.sqlalchemy.datetime_types.YqlTimestamp64 `.
0 commit comments