summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/mysql/mysqldb.py
Commit message (Collapse)AuthorAgeFilesLines
* fix: Update reserved words list of MySQL / MariaDB dialectKevin Kirsche2021-10-201-5/+1
| | | | | | | | | | | | | | | | | | | | | | | Reorganized the list of reserved words into two separate lists, one for MySQL and one for MariaDB, so that these diverging sets of words can be managed more accurately; adjusted the MySQL/MariaDB dialect to switch among these lists based on either explicitly configured or server-version-detected "MySQL" or "MariaDB" backend. Added all current reserved words through MySQL 8 and current MariaDB versions including recently added keywords like "lead" . Pull request courtesy Kevin Kirsche. 1. Move reserved words to it's own file. 2. Add missing reserved words from https://mariadb.com/kb/en/reserved-words/ * Note: this only adds MariaDB though links to MySQL, it also does not include the reserved words for Oracle mode, as listed in the link. Fixes: #7167 Supercedes: #7197 Closes: #7207 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7207 Pull-request-sha: 5a682e331069520ccad9e6bf3cc5e4a77a889ef0 Change-Id: Ib25be8148568899f56b5c9b42d4f530ade8a04e3
* Replace all http:// links to https://Federico Caselli2021-07-041-2/+2
| | | | | | Also replace http://pypi.python.org/pypi with https://pypi.org/project Change-Id: I84b5005c39969a82140706472989f2a30b0c7685
* add ssl_check_hostname option in mysqldbJerry Zhao2021-05-071-3/+59
| | | | | | | | | | | | | Added support for the ``ssl_check_hostname=`` parameter in mysql connection URIs and updated the mysql dialect documentation regarding secure connections. Original pull request courtesy of Jerry Zhao. Fixes: #5397 Closes: #5759 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5759 Pull-request-sha: 75f4bdc68d4b5745c518472e8bc2b02cec0f81e6 Change-Id: I964bfa7a4c15e215a3ad6e2b907cb78f5b3e5036
* Default caching to opt-out for 3rd party dialectsMike Bayer2021-04-011-0/+1
| | | | | | | | | | | | | | | | | | | Added a new flag to the :class:`_engine.Dialect` class called :attr:`_engine.Dialect.supports_statement_cache`. This flag now needs to be present directly on a dialect class in order for SQLAlchemy's :ref:`query cache <sql_caching>` to take effect for that dialect. The rationale is based on discovered issues such as :ticket:`6173` revealing that dialects which hardcode literal values from the compiled statement, often the numerical parameters used for LIMIT / OFFSET, will not be compatible with caching until these dialects are revised to use the parameters present in the statement only. For third party dialects where this flag is not applied, the SQL logging will show the message "dialect does not support caching", indicating the dialect should seek to apply this flag once they have verified that no per-statement literal values are being rendered within the compilation phase. Fixes: #6184 Change-Id: I6fd5b5d94200458d4cb0e14f2f556dbc25e27e22
* Update connect args for pymysql 1.0.0; aiomysql fixesMike Bayer2021-01-071-4/+7
| | | | | | | | | | | | | Fixed deprecation warnings that arose as a result of the release of PyMySQL 1.0, including deprecation warnings for the "db" and "passwd" parameters now replaced with "database" and "password". For the 1.4 version of this patch, we are also changing tox.ini to refer to a local branch of aiomysql that fixes pymysql compatibility issues. Fixes: #5821 Change-Id: I93876b52b2d96b52308f22aeb4f244ac5766a82f
* happy new yearMike Bayer2021-01-041-1/+1
| | | | Change-Id: Ic5bb19ca8be3cb47c95a0d3315d84cb484bac47c
* add aiomysql supportMike Bayer2020-12-101-4/+13
| | | | | | | | | This is a re-gerrit of the original gerrit merged in Ia8ad3efe3b50ce75a3bed1e020e1b82acb5f2eda Reverted due to ongoing issues. Fixes: #5747 Change-Id: I2b57e76b817eed8f89457a2146b523a1cab656a8
* Revert "Merge "add aiomysql support""Mike Bayer2020-12-091-13/+4
| | | | | | | | | | | | | | | | | This reverts commit 23343f87f3297ad31d7315ac0e5312db10ef7592, reversing changes made to c5831b1abd98c46ef7eab7ee82ead18756aea112. The crashes that occur in jenkins have not been solved and are now impacting master. I am not able to reproduce the failure, including running on the CI machines directly, and a few runs where I sat there for 20 minutes and watched, it didn't happen. it is the ultimate heisenbug. Additionally, there's a reference to "arraysize" that doesn't exist in fetchmany() and there seem to be no tests that exercise this for any DBAPI which is also a major bug to be fixed. References: #5747
* add aiomysql supportMike Bayer2020-12-081-4/+13
| | | | | Fixes: #5747 Change-Id: Ia8ad3efe3b50ce75a3bed1e020e1b82acb5f2eda
* Revert "Added ssl_mode flag to mysqldb"Mike Bayer2020-11-131-1/+0
| | | | | | | | | | | | | This reverts commit 2e4dec934cb5215d628e02ed717454c165a33e4d. I approved this merge before observing that the "ssl_mode" flag is not actually part of the separate "ssl" dictionary, so this patch as given is unnecessary as we already pass all strings into opts. but also I can't get the flag to work on either mysqlclient or pymysql, it's not recognized. so I need specific info from the submitter what it is that is actually needed, and if a change is needed it has to be appropriate for the drivers in use.
* Added ssl_mode flag to mysqldbGord Thompson2020-11-131-0/+1
| | | | | | | | | | | | | | | | | | | Fixes: #5692 ssl_mode flag is added to mysqldb ### Description mysqldb driver supports "ssl_mode" flag, which can be one of following values: "DISABLED", "PREFERRED", "REQUIRED", "VERIFY_CA", "VERIFY_IDENTITY". Depending on these values MySQL will behave accordingly to them. So this flag has been added to the sqlaclhemy. So in case if TLS is not supported on the server, we can drop the connection right away. Closes: #5693 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5693 Pull-request-sha: 94aed8b17d21da9a20be4b092f6a60b12f60b761 Change-Id: I7657b9c812d3a40ccacebbd8f4d5f20659d447c3
* Deprecate engine-wise ss cursors; repair mariadbconnectorMike Bayer2020-09-131-2/+1
| | | | | | | | | | | | | | | | | | | The server_side_cursors engine-wide feature relies upon regexp parsing of statements a well as general guessing as to when the feature should be used. This is not within the 2.0 way of doing things and should be removed. Additionally, mariadbconnector defaults to unbuffered cursors; add new cursor hooks so that mariadbconnector can specify buffered or unbuffered cursors without too much difficulty. This will also correctly default mariadbconnector to buffered cursors which should repair the segfaults we've been getting. Try to restore the assert_raises that was removed in 5b6dfc0c38bf1f01da4b8 to see if mariadbconnector segfaults are resolved. Change-Id: I77f1c972c742e40694972f578140bb0cac8c39eb
* Deprecate plain string in execute and introduce `exec_driver_sql`Federico Caselli2020-03-211-4/+3
| | | | | | | | | | | | | | | Execution of literal sql string is deprecated in the :meth:`.Connection.execute` and a warning is raised when used stating that it will be coerced to :func:`.text` in a future release. To execute a raw sql string the new connection method :meth:`.Connection.exec_driver_sql` was added, that will retain the previous behavior, passing the string to the DBAPI driver unchanged. Usage of scalar or tuple positional parameters in :meth:`.Connection.execute` is also deprecated. Fixes: #4848 Fixes: #5178 Change-Id: I2830181054327996d594f7f0d59c157d477c3aa9
* happy new yearMike Bayer2020-01-011-1/+1
| | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Emit SET NAMES for all MySQL connections w charsetMike Bayer2019-08-111-0/+16
| | | | | | | | | | | | | | | | | The MySQL dialects will emit "SET NAMES" at the start of a connection when charset is given to the MySQL driver, to appease an apparent behavior observed in MySQL 8.0 that raises a collation error when a UNION includes string columns unioned against columns of the form CAST(NULL AS CHAR(..)), which is what SQLAlchemy's polymorphic_union function does. The issue seems to have affected PyMySQL for at least a year, however has recently appeared as of mysqlclient 1.4.4 based on changes in how this DBAPI creates a connection. As the presence of this directive impacts three separate MySQL charset settings which each have intricate effects based on their presense, SQLAlchemy will now emit the directive on new connections to ensure correct behavior. Fixes: #4804 Change-Id: If9d7ee00d0ccaf773972b564fe455e8e9edf6627
* Feature mysqlclientMike Bayer2019-01-181-10/+12
| | | | | | | | MySQL-Python hasn't been released in about five years and there is no reason that it should be listed as a viable DBAPI; all MySQL / MariaDB users should be using mysqlclient or PyMySQL today. Change-Id: I2f12babe6e60bc7393398400a125d0592e86dbb8
* happy new yearMike Bayer2019-01-111-1/+1
| | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Post black reformattingMike Bayer2019-01-061-7/+6
| | | | | | | | | | | | | Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
* Run black -l 79 against all source filesMike Bayer2019-01-061-51/+68
| | | | | | | | | | | | | | This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
* Add the write_timeout option for mysql.jun923.gu2018-11-301-0/+1
| | | | | | | | | | As MySQLdb support read_timeout and write_timeout option, and sqlalchemy just support read_timeout option. So sqlalchemy need to add write_timeout option. Fixes: #4381 Change-Id: I2bea80bdd6f20fafc72b48fa0e5d795626d9d9b9 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4385
* - also correct for dbapi is a Mock without __version__...Mike Bayer2018-10-201-1/+2
| | | | Change-Id: I9e6b61a3292a2a6c8bb281c2375f2326282bcb76
* - correct for dbapi not present in some testsMike Bayer2018-10-201-1/+1
| | | | Change-Id: Iaa81a00658060d40add26c95cc69cee7edd5966a
* Enable decimal implicit bind for mysqlclient, is fixed as ofMike Bayer2018-10-201-0/+12
| | | | | | post 1.3.13 Change-Id: Ic7a2055597d06038ab330f1114416e4538964a2b
* Use MySQL protocol-level ping.Maxim Bublis2018-07-091-0/+11
| | | | | | | | | | Utilizes MySQL protocol-level pings for disconnection detection. This is just a 5-byte packet followed by a 7-byte response. Affects MySQLdb, MySQL Connector and PyMySQL dialects. Change-Id: I672f75e3746878d88987a31750444dde0cf8eb9b Pull-request: https://github.com/zzzeek/sqlalchemy/pull/460
* Use utf8mb4 (or utf8mb3) for all things MySQLMike Bayer2018-06-251-5/+5
| | | | | | | | | | | | | | | | | Fixed bug in MySQLdb dialect and variants such as PyMySQL where an additional "unicode returns" check upon connection makes explicit use of the "utf8" character set, which in MySQL 8.0 emits a warning that utf8mb4 should be used. This is now replaced with a utf8mb4 equivalent. Documentation is also updated for the MySQL dialect to specify utf8mb4 in all examples. Additional changes have been made to the test suite to use utf8mb3 charsets and databases (there seem to be collation issues in some edge cases with utf8mb4), and to support configuration default changes made in MySQL 8.0 such as explicit_defaults_for_timestamp as well as new errors raised for invalid MyISAM indexes. Change-Id: Ib596ea7de4f69f976872a33bffa4c902d17dea25 Fixes: #4283 Fixes: #4192
* Get MySQL version info from @@versionMike Bayer2018-03-031-11/+0
| | | | | | | | | | | | | MySQL dialects now query the server version using ``SELECT @@version`` explicitly to the server to ensure we are getting the correct version information back. Proxy servers like MaxScale interfere with the value that is passed to the DBAPI's connection.server_version value so this is no longer reliable. Change-Id: Iafd39be8c9bf1982d58b34cc997ae1016ad6c48c Fixes: #4205 (cherry picked from commit 9ba77e8d3b682bff89fdab5e80271a96a52fe8c8) (cherry picked from commit 5c1ebbc3706c810f936d9e252ee5d16800e561ea)
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* Double percent signs based on paramstyle, not dialectMike Bayer2017-04-051-10/+2
| | | | | | | | | | | | This patch moves the "doubling" of percent signs into the base compiler and makes it completely a product of whether or not the paramstyle is format/pyformat or not. Without this paramstyle, percent signs are not doubled across text(), literal_column(), and column(). Change-Id: Ie2f278ab1dbb94b5078f85c0096d74dbfa049197 Fixes: #3740
* Support python3.6Mike Bayer2017-01-131-1/+1
| | | | | | | | | | | Corrects some warnings and adds tox config. Adds DeprecationWarning to the error category. Large sweep for string literals w/ backslashes as this is common in docstrings Co-authored-by: Andrii Soldatenko Fixes: #3886 Change-Id: Ia7c838dfbbe70b262622ed0803d581edc736e085 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/337
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Add support for server side cursors to mysqldb and pymysqlRoman Podoliaka2016-11-101-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows to skip buffering of the results on the client side, e.g. the following snippet: table = sa.Table( 'testtbl', sa.MetaData(), sa.Column('id', sa.Integer, primary_key=True), sa.Column('a', sa.Integer), sa.Column('b', sa.String(512)) ) table.create(eng, checkfirst=True) with eng.connect() as conn: result = conn.execute(table.select().limit(1)).fetchone() if result is None: for _ in range(1000): conn.execute( table.insert(), [{'a': random.randint(1, 100000), 'b': ''.join(random.choice(string.ascii_letters) for _ in range(100))} for _ in range(1000)] ) with eng.connect() as conn: for row in conn.execution_options(stream_results=True).execute(table.select()): pass now uses ~23 MB of memory instead of ~327 MB on CPython 3.5.2 and PyMySQL 0.7.9. psycopg2 implementation and execution options (stream_results, server_side_cursors) are reused. Change-Id: I4dc23ce3094f027bdff51b896b050361991c62e2
* Merge branch 'master' into pr157Mike Bayer2016-03-151-19/+10
|\
| * - happy new yearMike Bayer2016-01-291-1/+1
| |
| * - more updates to the unicode mess to frame this inMike Bayer2015-03-221-30/+2
| | | | | | | | as up-to-date recommendations as possible
| * Merge branch 'mysqlclient' of https://bitbucket.org/methane/sqlalchemy into pr48Mike Bayer2015-03-201-0/+9
| |\ | | | | | | | | | | | | Conflicts: lib/sqlalchemy/dialects/mysql/mysqldb.py
| | * Add mention about mysqlclientINADA Naoki2015-03-141-2/+4
| | |
| * | - reorganize MySQL docs re: unicode, other cleanup and updatesMike Bayer2015-03-201-11/+9
| | |
| * | add utf8mb4 recommendationThomas Grainger2015-03-181-0/+12
| |/
| * - copyright 2015Mike Bayer2015-03-101-1/+1
| |
* | Add 'native' autocommit support for mysql driverspr/157Roman Podoliaka2015-02-241-0/+12
|/ | | | | | Sometimes it might be useful to have 'native' autocommit support provided by a DB API driver rather than rely on SQLAlchemy autocommit emulation.
* - make the google deprecation messages more specific, use full URLMike Bayer2014-12-191-0/+8
| | | | | | format - add an extra doc to MySQLdb - changelog
* - Added a version check to the MySQLdb dialect surrounding theMike Bayer2014-12-161-6/+7
| | | | | check for 'utf8_bin' collation, as this fails on MySQL server < 5.0. fixes #3274
* - Updated the "supports_unicode_statements" flag to True for MySQLdbMike Bayer2014-12-041-1/+1
| | | | | | | | | and Pymysql under Python 2. This refers to the SQL statements themselves, not the parameters, and affects issues such as table and column names using non-ASCII characters. These drivers both appear to support Python 2 Unicode objects without issue in modern versions. fixes #3121
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-17/+17
| | | | sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* - remove drizzle dialectMike Bayer2014-05-301-20/+123
| | | | | - restore mysqldb fully within dialects/mysql/, it's no longer a connector. fixes #2984
* cut out the BS as far as MySQLdb urls, put the one url everyone should be usingMike Bayer2014-03-041-22/+14
|
* - The MySQL CAST compilation now takes into account aspects of a stringMike Bayer2014-01-131-1/+25
| | | | | | | | | | | | | | | | | | | | | type such as "charset" and "collation". While MySQL wants all character- based CAST calls to use the CHAR type, we now create a real CHAR object at CAST time and copy over all the parameters it has, so that an expression like ``cast(x, mysql.TEXT(charset='utf8'))`` will render ``CAST(t.col AS CHAR CHARACTER SET utf8)``. - Added new "unicode returns" detection to the MySQL dialect and to the default dialect system overall, such that any dialect can add extra "tests" to the on-first-connect "does this DBAPI return unicode directly?" detection. In this case, we are adding a check specifically against the "utf8" encoding with an explicit "utf8_bin" collation type (after checking that this collation is available) to test for some buggy unicode behavior observed with MySQLdb version 1.2.3. While MySQLdb has resolved this issue as of 1.2.4, the check here should guard against regressions. The change also allows the "unicode" checks to log in the engine logs, which was not previously the case. [ticket:2906]
* - happy new yearMike Bayer2014-01-051-1/+1
|
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|