~ubuntu-branches/debian/jessie/sqlalchemy/jessie

« back to all changes in this revision

Viewing changes to lib/sqlalchemy/connectors/mysqldb.py

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski, Jakub Wilk, Piotr Ożarowski
  • Date: 2013-07-06 20:53:52 UTC
  • mfrom: (1.4.23) (16.1.17 experimental)
  • Revision ID: package-import@ubuntu.com-20130706205352-ryppl1eto3illd79
Tags: 0.8.2-1
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Piotr Ożarowski ]
* New upstream release
* Upload to unstable
* Build depend on python3-all instead of -dev, extensions are not built for
  Python 3.X 

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
"""
6
6
 
7
 
from sqlalchemy.connectors import Connector
8
 
from sqlalchemy.engine import base as engine_base, default
9
 
from sqlalchemy.sql import operators as sql_operators
10
 
from sqlalchemy import exc, log, schema, sql, types as sqltypes, util
11
 
from sqlalchemy import processors
 
7
from . import Connector
 
8
from ..engine import base as engine_base, default
 
9
from ..sql import operators as sql_operators
 
10
from .. import exc, log, schema, sql, types as sqltypes, util, processors
12
11
import re
13
12
 
 
13
 
14
14
# the subclassing of Connector by all classes
15
15
# here is not strictly necessary
16
16
 
 
17
 
17
18
class MySQLDBExecutionContext(Connector):
18
19
 
19
20
    @property
23
24
        else:
24
25
            return self.cursor.rowcount
25
26
 
 
27
 
26
28
class MySQLDBCompiler(Connector):
27
 
    def visit_mod(self, binary, **kw):
28
 
        return self.process(binary.left) + " %% " + self.process(binary.right)
 
29
    def visit_mod_binary(self, binary, operator, **kw):
 
30
        return self.process(binary.left, **kw) + " %% " + \
 
31
                    self.process(binary.right, **kw)
29
32
 
30
33
    def post_process_text(self, text):
31
34
        return text.replace('%', '%%')
32
35
 
 
36
 
33
37
class MySQLDBIdentifierPreparer(Connector):
34
38
 
35
39
    def _escape_identifier(self, value):
36
40
        value = value.replace(self.escape_quote, self.escape_to_quote)
37
41
        return value.replace("%", "%%")
38
42
 
 
43
 
39
44
class MySQLDBConnector(Connector):
40
45
    driver = 'mysqldb'
41
46
    supports_unicode_statements = False
63
68
 
64
69
        util.coerce_kw_type(opts, 'compress', bool)
65
70
        util.coerce_kw_type(opts, 'connect_timeout', int)
 
71
        util.coerce_kw_type(opts, 'read_timeout', int)
66
72
        util.coerce_kw_type(opts, 'client_flag', int)
67
73
        util.coerce_kw_type(opts, 'local_infile', int)
68
74
        # Note: using either of the below will cause all strings to be returned
75
81
        # query string.
76
82
 
77
83
        ssl = {}
78
 
        for key in ['ssl_ca', 'ssl_key', 'ssl_cert', 'ssl_capath', 'ssl_cipher']:
 
84
        keys = ['ssl_ca', 'ssl_key', 'ssl_cert', 'ssl_capath', 'ssl_cipher']
 
85
        for key in keys:
79
86
            if key in opts:
80
87
                ssl[key[4:]] = opts[key]
81
88
                util.coerce_kw_type(ssl, key[4:], str)
147
154
                    "combination of MySQL server and MySQL-python. "
148
155
                    "MySQL-python >= 1.2.2 is recommended.  Assuming latin1.")
149
156
                return 'latin1'
150