You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After running a query, you can fetch information about the results using the same ``cursor`` object. The examples
233
+
below are from the last SELECT query in :ref:`connecting_and_queries:Inserting and selecting data`.
183
234
184
-
**Returns**: ``[2, 'world']``
235
+
.. _result_information_example:
185
236
186
-
::
237
+
**rowcount**
187
238
188
-
print(cursor.fetchmany(2))
239
+
- For a SELECT query, rowcount is the number of rows selected.
240
+
- For An INSERT query, it is always -1.
241
+
- For DDL (CREATE/DROP), it is always 1
189
242
190
-
**Returns**: ``[[1, 'hello'], [3, '!']]``
243
+
::
244
+
245
+
print("Rowcount: ", cursor.rowcount)
191
246
192
-
::
247
+
**Returns**: ``Rowcount: 3``
248
+
249
+
250
+
**description**
251
+
252
+
description is a list of Column objects, each one responsible for a single column in a result set. Only name and type_code fields get populated, all others are always empty.
253
+
254
+
- name is the name of the column.
255
+
- type_code is the data type of the column. It can be:
256
+
257
+
- a python type (int, float, str, date, datetime)
258
+
- an ARRAY object, that signifies a list of some type. The inner type can is stored in ``.subtype`` field
259
+
- a DECIMAL object, that signifies a decimal value. It’s precision and scale are stored in ``.precision`` and ``.scale`` fields
260
+
- a DATETIME64 object, that signifies a datetime value with an extended precision. The precision is stored in ``.precision``
0 commit comments