File: module.rst

package info (click to toggle)
mariadb-connector-python 1.1.14-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 948 kB
  • sloc: python: 6,288; ansic: 4,973; sh: 23; makefile: 14
file content (180 lines) | stat: -rw-r--r-- 4,213 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
The MariaDB Connector/Python module
===================================

.. _module:

.. sectionauthor:: Georg Richter <georg@mariadb.com>

.. automodule:: mariadb


Constructors 
------------

----------
Connection
----------

.. autofunction:: mariadb.connect(connectionclass=mariadb.connections.Connection, **kwargs)

.. note::
    For a description of configuration file handling and settings please read the chapter `Configuration files <https://github.com/mariadb-corporation/mariadb-connector-c/wiki/config_files#configuration-options>`_ of the MariaDB Connector/C documentation.

Example:

.. testcode::

    import mariadb

    with mariadb.connect(user="example_user", host="localhost", database="test", password="GHbe_Su3B8") as connection:
        print(connection.character_set)

Output:

.. testoutput::

    utf8mb4

---------------
Connection Pool
---------------

.. autofunction:: mariadb.ConnectionPool(**kwargs)

-----------------
Type constructors
-----------------

.. autofunction:: mariadb.Binary()

.. autofunction:: mariadb.Date(year, month, day)

.. autofunction:: mariadb.DateFromTicks(ticks)

.. autofunction:: mariadb.Time(hour, minute, second)

.. autofunction:: mariadb.TimeFromTicks(ticks)

.. autofunction:: mariadb.Timestamp(year, month, day, hour, minute, second)

.. autofunction:: mariadb.TimestampFromTicks(ticks)

Attributes
----------

.. attribute:: apilevel

    String constant stating the supported DB API level. The value for `mariadb` is
    ``2.0``.

.. attribute:: threadsafety

    Integer constant stating the level of thread safety. For `mariadb` the value is 1,
    which means threads can share the module but not the connection.

.. attribute:: paramstyle

    String constant stating the type of parameter marker. For `mariadb` the value is
    `qmark`. For compatibility reasons `mariadb` also supports the `format` and
    `pyformat` paramstyles with the limitation that they can't be mixed inside a SQL statement.

.. attribute:: mariadbapi_version

    String constant stating the version of the used MariaDB Connector/C library.

.. attribute:: client_version

    *Since version 1.1.0*

    Returns the version of MariaDB Connector/C library in use as an integer.
    The number has the following format:
    MAJOR_VERSION * 10000 + MINOR_VERSION * 1000 + PATCH_VERSION

.. attribute:: client_version_info

    *Since version 1.1.0*
    Returns the version of MariaDB Connector/C library as a tuple in the
    following format:
    (MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)


Exceptions
----------

Compliant to DB API 2.0 MariaDB Connector/C provides information about errors
through the following exceptions:

.. autoexception:: mariadb.DataError

.. autoexception:: mariadb.DatabaseError

.. autoexception:: mariadb.InterfaceError

.. autoexception:: mariadb.Warning

.. autoexception:: mariadb.PoolError

.. autoexception:: mariadb.OperationalError

.. autoexception:: mariadb.IntegrityError

.. autoexception:: mariadb.InternalError

.. autoexception:: mariadb.ProgrammingError

.. autoexception:: mariadb.NotSupportedError

------------
Type objects 
------------

..
     _Note: Type objects are handled as constants, therefore we can't
     use autodata.

MariaDB Connector/Python type objects are immutable sets for type settings
and defined in DBAPI 2.0 (PEP-249).

Example:

.. testcode::

    import mariadb
    from mariadb.constants import FIELD_TYPE

    print(FIELD_TYPE.GEOMETRY == mariadb.BINARY)
    print(FIELD_TYPE.DATE == mariadb.DATE)
    print(FIELD_TYPE.VARCHAR == mariadb.BINARY)

Output:

.. testoutput::

    True
    True
    False

.. data:: STRING

    This type object is used to describe columns in a database that are
    string-based (e.g. CHAR1).

.. data:: BINARY

    This type object is used to describe (long) binary columns in a database
    (e.g. LONG, RAW, BLOBs).

.. data:: NUMBER

    This type object is used to describe numeric columns in a database.

.. data:: DATETIME

    This type object is used to describe date/time columns in a database.

.. data:: ROWID

    This type object is not supported in MariaDB Connector/Python and represents
    an empty set.

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