mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2026-03-13 08:00:02 +08:00
Move _mysql and _mysql_exceptions into MySQLdb/ (#293)
This commit is contained in:
@@ -15,7 +15,7 @@ MySQLdb.converters module.
|
||||
|
||||
from MySQLdb.release import __version__, version_info, __author__
|
||||
|
||||
import _mysql
|
||||
from . import _mysql
|
||||
|
||||
if version_info != _mysql.version_info:
|
||||
raise ImportError("this is MySQLdb version %s, but _mysql is version %r" %
|
||||
@@ -25,7 +25,7 @@ threadsafety = 1
|
||||
apilevel = "2.0"
|
||||
paramstyle = "format"
|
||||
|
||||
from _mysql import *
|
||||
from ._mysql import *
|
||||
from MySQLdb.compat import PY2
|
||||
from MySQLdb.constants import FIELD_TYPE
|
||||
from MySQLdb.times import Date, Time, Timestamp, \
|
||||
|
||||
@@ -2746,7 +2746,7 @@ init_mysql(void)
|
||||
(PyObject *)&_mysql_ResultObject_Type))
|
||||
goto error;
|
||||
Py_INCREF(&_mysql_ResultObject_Type);
|
||||
if (!(emod = PyImport_ImportModule("_mysql_exceptions"))) {
|
||||
if (!(emod = PyImport_ImportModule("MySQLdb._mysql_exceptions"))) {
|
||||
PyErr_Print();
|
||||
goto error;
|
||||
}
|
||||
@@ -7,14 +7,13 @@ override Connection.default_cursor with a non-standard Cursor class.
|
||||
import re
|
||||
import sys
|
||||
|
||||
from MySQLdb import cursors
|
||||
from MySQLdb import cursors, _mysql
|
||||
from MySQLdb.compat import unicode, PY2
|
||||
from _mysql_exceptions import (
|
||||
from MySQLdb._mysql_exceptions import (
|
||||
Warning, Error, InterfaceError, DataError,
|
||||
DatabaseError, OperationalError, IntegrityError, InternalError,
|
||||
NotSupportedError, ProgrammingError,
|
||||
)
|
||||
import _mysql
|
||||
|
||||
|
||||
if not PY2:
|
||||
|
||||
@@ -31,7 +31,7 @@ Don't modify conversions if you can avoid it. Instead, make copies
|
||||
MySQL.connect().
|
||||
"""
|
||||
|
||||
from _mysql import string_literal, escape, NULL
|
||||
from MySQLdb._mysql import string_literal, escape, NULL
|
||||
from MySQLdb.constants import FIELD_TYPE, FLAG
|
||||
from MySQLdb.times import *
|
||||
from MySQLdb.compat import PY2, long
|
||||
|
||||
@@ -8,8 +8,8 @@ from functools import partial
|
||||
import re
|
||||
import sys
|
||||
|
||||
from MySQLdb.compat import unicode
|
||||
from _mysql_exceptions import (
|
||||
from .compat import unicode
|
||||
from ._mysql_exceptions import (
|
||||
Warning, Error, InterfaceError, DataError,
|
||||
DatabaseError, OperationalError, IntegrityError, InternalError,
|
||||
NotSupportedError, ProgrammingError)
|
||||
@@ -55,9 +55,11 @@ class BaseCursor(object):
|
||||
#: Default value of max_allowed_packet is 1048576.
|
||||
max_stmt_length = 64*1024
|
||||
|
||||
from _mysql_exceptions import MySQLError, Warning, Error, InterfaceError, \
|
||||
DatabaseError, DataError, OperationalError, IntegrityError, \
|
||||
InternalError, ProgrammingError, NotSupportedError
|
||||
from ._mysql_exceptions import (
|
||||
MySQLError, Warning, Error, InterfaceError,
|
||||
DatabaseError, DataError, OperationalError, IntegrityError,
|
||||
InternalError, ProgrammingError, NotSupportedError,
|
||||
)
|
||||
|
||||
_defer_warnings = False
|
||||
connection = None
|
||||
|
||||
@@ -6,7 +6,7 @@ Use Python datetime module to handle date and time columns.
|
||||
"""
|
||||
from time import localtime
|
||||
from datetime import date, datetime, time, timedelta
|
||||
from _mysql import string_literal
|
||||
from MySQLdb._mysql import string_literal
|
||||
|
||||
Date = date
|
||||
Time = time
|
||||
|
||||
@@ -17,11 +17,11 @@ Installation
|
||||
The ``README`` file has complete installation instructions.
|
||||
|
||||
|
||||
_mysql
|
||||
------
|
||||
MySQLdb._mysql
|
||||
--------------
|
||||
|
||||
If you want to write applications which are portable across databases,
|
||||
use MySQLdb_, and avoid using this module directly. ``_mysql``
|
||||
use MySQLdb_, and avoid using this module directly. ``MySQLdb._mysql``
|
||||
provides an interface which mostly implements the MySQL C API. For
|
||||
more information, see the `MySQL documentation`_. The documentation
|
||||
for this module is intentionally weak because you probably should use
|
||||
|
||||
@@ -31,7 +31,7 @@ classifiers:
|
||||
Topic :: Database
|
||||
Topic :: Database :: Database Engines/Servers
|
||||
py_modules:
|
||||
_mysql_exceptions
|
||||
MySQLdb._mysql_exceptions
|
||||
MySQLdb.compat
|
||||
MySQLdb.connections
|
||||
MySQLdb.converters
|
||||
|
||||
4
setup.py
4
setup.py
@@ -14,7 +14,9 @@ with io.open('README.md', encoding='utf-8') as f:
|
||||
readme = f.read()
|
||||
|
||||
metadata, options = get_config()
|
||||
metadata['ext_modules'] = [setuptools.Extension(sources=['_mysql.c'], **options)]
|
||||
metadata['ext_modules'] = [
|
||||
setuptools.Extension("MySQLdb._mysql", sources=['MySQLdb/_mysql.c'], **options)
|
||||
]
|
||||
metadata['long_description'] = readme
|
||||
metadata['long_description_content_type'] = "text/markdown"
|
||||
setuptools.setup(**metadata)
|
||||
|
||||
@@ -94,7 +94,6 @@ def get_config():
|
||||
create_release_file(metadata)
|
||||
del metadata['version_info']
|
||||
ext_options = dict(
|
||||
name = "_mysql",
|
||||
library_dirs = library_dirs,
|
||||
libraries = libraries,
|
||||
extra_compile_args = extra_compile_args,
|
||||
@@ -102,7 +101,7 @@ def get_config():
|
||||
include_dirs = include_dirs,
|
||||
extra_objects = extra_objects,
|
||||
define_macros = define_macros,
|
||||
)
|
||||
)
|
||||
|
||||
# newer versions of gcc require libstdc++ if doing a static build
|
||||
if static:
|
||||
|
||||
@@ -35,7 +35,6 @@ def get_config():
|
||||
create_release_file(metadata)
|
||||
del metadata['version_info']
|
||||
ext_options = dict(
|
||||
name = "_mysql",
|
||||
library_dirs = library_dirs,
|
||||
libraries = libraries,
|
||||
extra_compile_args = extra_compile_args,
|
||||
@@ -43,7 +42,7 @@ def get_config():
|
||||
include_dirs = include_dirs,
|
||||
extra_objects = extra_objects,
|
||||
define_macros = define_macros,
|
||||
)
|
||||
)
|
||||
return metadata, ext_options
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import unittest
|
||||
|
||||
import _mysql
|
||||
from MySQLdb import _mysql
|
||||
import MySQLdb
|
||||
from MySQLdb.constants import FIELD_TYPE
|
||||
from configdb import connection_factory
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
import _mysql
|
||||
from MySQLdb import _mysql
|
||||
|
||||
|
||||
def test_result_type():
|
||||
|
||||
Reference in New Issue
Block a user