File: constants.rst

package info (click to toggle)
mariadb-connector-python 1.1.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 952 kB
  • sloc: python: 6,288; ansic: 4,973; sh: 23; makefile: 14
file content (397 lines) | stat: -rw-r--r-- 7,661 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
Constants
====================

  Constants are declared in mariadb.constants module.
 
  For using constants of various types, they have to be imported first:

.. code-block:: python

    from mariadb.constants import *

----------
CAPABILITY
----------

.. automodule:: mariadb.constants.CAPABILITY

   *Since version 1.1.4*

.. testcode::

    import mariadb
    from mariadb.constants import *

    # connection parameters
    conn_params= {
        "user" : "example_user",
        "password" : "GHbe_Su3B8",
        "host" : "localhost"
    }

    with mariadb.connect(**conn_params) as connection:
        # test if LOAD DATA LOCAL INFILE is supported
        if connection.server_capabilities & CAPABILITY.LOCAL_FILES:
            print("Server supports LOCAL INFILE")
    
*Output*:

.. testoutput::

    Server supports LOCAL INFILE


--------------
CLIENT
--------------

.. automodule:: mariadb.constants.CLIENT

   *Since version 1.1.0, deprecated in 1.1.4*

--------------
CURSOR
--------------

.. automodule:: mariadb.constants.CURSOR

   *Since version 1.1.0*

.. py:data:: CURSOR.NONE

   This is the default setting (no cursor)

.. py:data:: CURSOR.READ_ONLY

   Will create a server side read only cursor. The cursor is a forward cursor, which
   means it is not possible to scroll back.

--------------
ERR (Error)
--------------

Using ERR constants instead of error numbers make the code more readable. Error constants
are defined in constants.ERR module

*Since version 1.1.2*

.. testcode::

    import mariadb
    from mariadb.constants import *

    # connection parameters
    conn_params= {
        "user" : "example_user",
        "password" : "wrong_password",
        "host" : "localhost"
    }

    # try to establish a connection
    try:
        connection= mariadb.connect(**conn_params)
    except mariadb.OperationalError as Err:
        if Err.errno == ERR.ER_ACCESS_DENIED_ERROR:
            print("Access denied. Wrong password!") 

*Output*:

.. testoutput::

    Access denied. Wrong password!

--------------
FIELD_FLAG
--------------

.. automodule:: mariadb.constants.FIELD_FLAG

   *Since version 1.1.0*


.. py:data:: FIELD_FLAG.NOT_NULL

   column is defined as not NULL

.. py:data:: FIELD_FLAG.PRIMARY_KEY

   column is (part of) a primary key

.. py:data:: FIELD_FLAG.UNIQUE_KEY

   column is (part of) a unique key 

.. py:data:: FIELD_FLAG.MULTIPLE_KEY

   column is (part of) a key

.. py:data:: FIELD_FLAG.BLOB

   column contains a binary object

.. py:data:: FIELD_FLAG.UNSIGNED

   numeric column is defined as unsigned

.. py:data:: FIELD_FLAG.ZEROFILL

   column has zerofill attribute

.. py:data:: FIELD_FLAG.BINARY

   column is a binary

.. py:data:: FIELD_FLAG.ENUM

   column is defined as enum

.. py:data:: FIELD_FLAG.AUTO_INCREMENT

   column is an auto_increment column

.. py:data:: FIELD_FLAG.TIMESTAMP

   column is defined as time stamp

.. py:data:: FIELD_FLAG.SET

   column is defined as SET

.. py:data:: FIELD_FLAG.NO_DEFAULT

   column hasn't a default value

.. py:data:: FIELD_FLAG.ON_UPDATE_NOW

   column will be set to current timestamp on UPDATE

.. py:data:: FIELD_FLAG.NUMERIC

   column contains numeric value

.. py:data:: FIELD_FLAG.PART_OF_KEY

   column is part of a key

----------
FIELD_TYPE
----------

.. automodule:: mariadb.constants.FIELD_TYPE

.. py:data:: FIELD_TYPE.TINY

   column type is TINYINT  (1-byte integer)

.. py:data:: FIELD_TYPE.SHORT

   column type is SMALLINT (2-byte integer)

.. py:data:: FIELD_TYPE.LONG

   column tyoe is INT (4-byte integer)

.. py:data:: FIELD_TYPE.FLOAT

   column type is FLOAT (4-byte single precision)

.. py:data:: FIELD_TYPE.DOUBLE

   column type is DOUBLE (8-byte double precision)

.. py:data:: FIELD_TYPE.NULL

   column type is NULL

.. py:data:: FIELD_TYPE.TIMESTAMP

   column tyoe is TIMESTAMP

.. py:data:: FIELD_TYPE.LONGLONG

   column tyoe is BIGINT (8-byte Integer)

.. py:data:: FIELD_TYPE.INT24

   column type is MEDIUMINT (3-byte Integer)

.. py:data:: FIELD_TYPE.DATE

   column type is DATE

.. py:data:: FIELD_TYPE.TIME

   column type is TIME

.. py:data:: FIELD_TYPE.DATETIME

   column type is YEAR

.. py:data:: FIELD_TYPE.YEAR

.. py:data:: FIELD_TYPE.VARCHAR

   column type is YEAR

.. py:data:: FIELD_TYPE.BIT

   column type is BIT

.. py:data:: FIELD_TYPE.JSON

   column type is JSON

.. py:data:: FIELD_TYPE.NEWDECIMAL

   column type is DECIMAL

.. py:data:: FIELD_TYPE.ENUM

   column type is ENUM

.. py:data:: FIELD_TYPE.SET

   column type is SET

.. py:data:: FIELD_TYPE.TINY_BLOB

   column type is TINYBLOB (max. length of 255 bytes)

.. py:data:: FIELD_TYPE.MEDIUM_BLOB

   column type is MEDIUMBLOB (max. length of 16,777,215 bytes)

.. py:data:: FIELD_TYPE.LONG_BLOB

   column type is LONGBLOB (max. length 4GB bytes)

.. py:data:: FIELD_TYPE.BLOB

   column type is BLOB (max. length of 65.535 bytes)

.. py:data:: FIELD_TYPE.VAR_STRING

   column type is VARCHAR (variable length)

.. py:data:: FIELD_TYPE.STRING

   column type is CHAR (fixed length)

.. py:data:: FIELD_TYPE.GEOMETRY

   column type is GEOMETRY

--------------
INDICATORS
--------------

Indicator values are used in executemany() method of cursor class to
indicate special values when connected to a MariaDB server 10.2 or newer.

.. py:data:: INDICATOR.NULL

indicates a NULL value

.. py:data:: INDICATOR.DEFAULT

indicates to use default value of column

.. py:data:: INDICATOR.IGNORE

indicates to ignore value for column for UPDATE statements.
If set, the column will not be updated.

.. py:data:: INDICATOR.IGNORE_ROW

indicates not to update the entire row.

---------------
INFO
---------------

For internal use only

---------------
TPC_STATE
---------------

For internal use only


---------------
STATUS
---------------
The STATUS constants are used to check the server status of the current connection.

*Since version 1.1.0*

  Example:

  .. code-block:: python

      cursor.callproc("my_storedprocedure", (1,"foo"))

      if (connection.server_status & STATUS.SP_OUT_PARAMS):
          print("retrieving output parameters from store procedure")
          ...
      else:
          print("retrieving data from stored procedure")
          ....
      

.. py:data:: STATUS.IN_TRANS

   Pending transaction

.. py:data:: STATUS.AUTOCOMMIT

   Server operates in autocommit mode

.. py:data:: STATUS.MORE_RESULTS_EXIST

   The result from last executed statement contained two or more result
   sets which can be retrieved by cursors nextset() method.

.. py:data:: STATUS.QUERY_NO_GOOD_INDEX_USED

   The last executed statement didn't use a good index.

.. py:data:: STATUS.QUERY_NO_INDEX_USED

   The last executed statement didn't use an index.

.. py:data:: STATUS.CURSOR_EXISTS

   The last executed statement opened a server side cursor.

.. py:data:: STATUS.LAST_ROW_SENT

   For server side cursors this flag indicates end of a result set.

.. py:data:: STATUS.DB_DROPPED

   The current database in use was dropped and there is no default
   database for the connection anymore.

.. py:data:: STATUS.NO_BACKSLASH_ESCAPES

   Indicates that SQL mode NO_BACKSLASH_ESCAPE is active, which means
   that the backslash character '\' becomes an ordinary character.

.. py:data:: STATUS.QUERY_WAS_SLOW

   The previously executed statement was slow (and needs to be optimized).

.. py:data:: STATUS.PS_OUT_PARAMS

   The current result set contains output parameters of a stored procedure.

.. py:data:: STATUS.SESSION_STATE_CHANGED

   The session status has been changed.

.. py:data:: STATUS.ANSI_QUOTES

   SQL mode ANSI_QUOTES is active,

{% @marketo/form formId=\"4316\" %}