diff --git a/requirement.txt b/requirement.txt new file mode 100644 index 0000000..fb52a4a --- /dev/null +++ b/requirement.txt @@ -0,0 +1,10 @@ +MySQL-python==1.2.3 +-e git+https://github.com/petehunt/PyMySQL.git@3656421dae1dfff4a431b2eb0e1d2b805e10b6ea#egg=PyMySQL-dev +distribute==0.6.19 +gevent==0.13.6 +greenlet==0.3.4 +mysql-ctypes==0.5 +nose==1.1.3.dev +-e git+git@github.com:hongqn/ultramysql.git@f5c5839a4f02473fbeaaa882771230d2e1fb9c35#egg=umysql-dev +-e git+http://code.dapps.douban.com/oursql.git@c3fc693d4b65b736615d5b74656a12f9cd70c014#egg=umysqldb-dev +wsgiref==0.1.2 diff --git a/setup.py b/setup.py index b72267c..f805233 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ import os from setuptools import setup, find_packages -from oursql import __version__ +from umysqldb import __version__ install_requires = [ 'umysql', @@ -8,7 +8,7 @@ ] setup( - name = 'oursql', + name = 'umysqldb', description = "MySQLdb compatible wrapper for ultramysql", long_description = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read(), diff --git a/tests/__init__.py b/tests/__init__.py index 72fbea2..064b451 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -2,11 +2,11 @@ def setup_package(): @apply def print_sqls(): print "patch" - import oursql.connections - orig_query = oursql.connections.Connection.query + import umysqldb.connections + orig_query = umysqldb.connections.Connection.query def query(self, *a, **kw): print "QUERY:", str(a)[:800], str(kw)[:800] return orig_query(self, *a, **kw) - oursql.connections.Connection.query = query + umysqldb.connections.Connection.query = query diff --git a/tests/test_oursql.py b/tests/test_oursql.py index 4e217d8..c6d8c24 100644 --- a/tests/test_oursql.py +++ b/tests/test_oursql.py @@ -1,7 +1,7 @@ from nose.tools import raises -import oursql +import umysqldb -@raises(oursql.err.OperationalError) +@raises(umysqldb.err.OperationalError) def test_access_denied_should_raise_OperationalError(): - oursql.connect(host='127.0.0.1', user='asdf', passwd='fdsa') + umysqldb.connect(host='127.0.0.1', user='asdf', passwd='fdsa') diff --git a/tests/thirdparty/test_MySQLdb/test_oursql_capabilities.py b/tests/thirdparty/test_MySQLdb/test_oursql_capabilities.py index d5aad80..adf319e 100644 --- a/tests/thirdparty/test_MySQLdb/test_oursql_capabilities.py +++ b/tests/thirdparty/test_MySQLdb/test_oursql_capabilities.py @@ -1,16 +1,16 @@ #!/usr/bin/env python import capabilities import unittest -import oursql +import umysqldb import warnings from nose.plugins.skip import SkipTest warnings.filterwarnings('error') -class test_oursql(capabilities.DatabaseTest): +class test_umysqldb(capabilities.DatabaseTest): - db_module = oursql + db_module = umysqldb connect_args = () connect_kwargs = dict(db='test', host='127.0.0.1', @@ -81,7 +81,7 @@ def generator(row,col): generator) def test_bug_2671682(self): - from oursql.constants import ER + from umysqldb.constants import ER try: self.cursor.execute("describe some_non_existent_table"); except self.connection.ProgrammingError, msg: diff --git a/tests/thirdparty/test_MySQLdb/test_oursql_dbapi20.py b/tests/thirdparty/test_MySQLdb/test_oursql_dbapi20.py index cf41651..d66a983 100644 --- a/tests/thirdparty/test_MySQLdb/test_oursql_dbapi20.py +++ b/tests/thirdparty/test_MySQLdb/test_oursql_dbapi20.py @@ -4,10 +4,10 @@ from nose.plugins.skip import SkipTest -import oursql +import umysqldb -class test_oursql(dbapi20.DatabaseAPI20Test): - driver = oursql +class test_umysqldb(dbapi20.DatabaseAPI20Test): + driver = umysqldb connect_args = () connect_kw_args = dict(db='test', host='127.0.0.1', diff --git a/tests/thirdparty/test_MySQLdb/test_oursql_nonstandard.py b/tests/thirdparty/test_MySQLdb/test_oursql_nonstandard.py index a7271cd..a952759 100644 --- a/tests/thirdparty/test_MySQLdb/test_oursql_nonstandard.py +++ b/tests/thirdparty/test_MySQLdb/test_oursql_nonstandard.py @@ -1,24 +1,24 @@ import unittest -import oursql -_mysql = oursql -from oursql.constants import FIELD_TYPE +import umysqldb +_mysql = umysqldb +from umysqldb.constants import FIELD_TYPE from nose.plugins.skip import SkipTest class TestDBAPISet(unittest.TestCase): def test_set_equality(self): - self.assertTrue(oursql.STRING == oursql.STRING) + self.assertTrue(umysqldb.STRING == umysqldb.STRING) def test_set_inequality(self): - self.assertTrue(oursql.STRING != oursql.NUMBER) + self.assertTrue(umysqldb.STRING != umysqldb.NUMBER) def test_set_equality_membership(self): - self.assertTrue(FIELD_TYPE.VAR_STRING == oursql.STRING) + self.assertTrue(FIELD_TYPE.VAR_STRING == umysqldb.STRING) def test_set_inequality_membership(self): - self.assertTrue(FIELD_TYPE.DATE != oursql.STRING) + self.assertTrue(FIELD_TYPE.DATE != umysqldb.STRING) class CoreModule(unittest.TestCase): @@ -67,7 +67,7 @@ def test_affected_rows(self): #def test_debug(self): ## FIXME Only actually tests if you lack SUPER - #self.assertRaises(oursql.OperationalError, + #self.assertRaises(umysqldb.OperationalError, #self.conn.dump_debug_info) def test_charset_name(self): diff --git a/tests/thirdparty/test_pymysql/base.py b/tests/thirdparty/test_pymysql/base.py index 4dad388..b529900 100644 --- a/tests/thirdparty/test_pymysql/base.py +++ b/tests/thirdparty/test_pymysql/base.py @@ -1,18 +1,18 @@ -import oursql +import umysqldb import unittest -class OurSQLTestCase(unittest.TestCase): +class UMySQLdbTestCase(unittest.TestCase): # Edit this to suit your test environment. databases = [ {"host":"127.0.0.1","user":"test", - "passwd":"","db":"test_oursql", "use_unicode": True}, - {"host":"127.0.0.1","user":"test","passwd":"","db":"test_oursql2"}] + "passwd":"","db":"test_umysqldb", "use_unicode": True}, + {"host":"127.0.0.1","user":"test","passwd":"","db":"test_umysqldb2"}] def setUp(self): self.connections = [] for params in self.databases: - self.connections.append(oursql.connect(**params)) + self.connections.append(umysqldb.connect(**params)) def tearDown(self): for connection in self.connections: diff --git a/tests/thirdparty/test_pymysql/test_DictCursor.py b/tests/thirdparty/test_pymysql/test_DictCursor.py index fe5b239..59d4c9a 100644 --- a/tests/thirdparty/test_pymysql/test_DictCursor.py +++ b/tests/thirdparty/test_pymysql/test_DictCursor.py @@ -1,14 +1,14 @@ import datetime -import oursql.cursors +import umysqldb.cursors from . import base -class TestDictCursor(base.OurSQLTestCase): +class TestDictCursor(base.UMySQLdbTestCase): def test_DictCursor(self): #all assert test compare to the structure as would come out from MySQLdb conn = self.connections[0] - c = conn.cursor(oursql.cursors.DictCursor) + c = conn.cursor(umysqldb.cursors.DictCursor) # create a table ane some data to query c.execute("""CREATE TABLE dictcursor (name char(20), age int , DOB datetime)""") data = (("bob",21,"1990-02-06 23:04:56"), diff --git a/tests/thirdparty/test_pymysql/test_SSCursor.py b/tests/thirdparty/test_pymysql/test_SSCursor.py index dd11589..79b9095 100644 --- a/tests/thirdparty/test_pymysql/test_SSCursor.py +++ b/tests/thirdparty/test_pymysql/test_SSCursor.py @@ -1,11 +1,11 @@ from . import base -import oursql.cursors +import umysqldb.cursors from nose.plugins.skip import SkipTest raise SkipTest("umysql does not support server-side cursor") -class TestSSCursor(base.OurSQLTestCase): +class TestSSCursor(base.UMySQLdbTestCase): def test_SSCursor(self): affected_rows = 18446744073709551615 @@ -24,7 +24,7 @@ def test_SSCursor(self): ('America', '', 'America/Detroit'),] try: - cursor = conn.cursor(oursql.cursors.SSCursor) + cursor = conn.cursor(umysqldb.cursors.SSCursor) # Create table cursor.execute(('CREATE TABLE tz_data (' diff --git a/tests/thirdparty/test_pymysql/test_basic.py b/tests/thirdparty/test_pymysql/test_basic.py index dd335c9..866af5e 100644 --- a/tests/thirdparty/test_pymysql/test_basic.py +++ b/tests/thirdparty/test_pymysql/test_basic.py @@ -4,13 +4,13 @@ from nose.plugins.skip import SkipTest -from oursql import util +from umysqldb import util from . import base def int2byte(i): return struct.pack("!B", i) -class TestConversion(base.OurSQLTestCase): +class TestConversion(base.UMySQLdbTestCase): def test_datatypes(self): """ test every data type """ conn = self.connections[0] @@ -93,7 +93,7 @@ def test_big_blob(self): c = conn.cursor() c.execute("create table test_big_blob (b blob)") try: - data = "oursql" * 1024 + data = "umysqldb" * 1024 c.execute("insert into test_big_blob (b) values (%s)", (data,)) c.execute("select b from test_big_blob") self.assertEqual(data.encode(conn.charset), c.fetchone()[0]) @@ -120,7 +120,7 @@ def test_datetime(self): c.fetchone()) -class TestCursor(base.OurSQLTestCase): +class TestCursor(base.UMySQLdbTestCase): # this test case does not work quite right yet, however, # we substitute in None for the erroneous field which is # compatible with the DB-API 2.0 spec and has not broken @@ -180,7 +180,7 @@ def test_fetch_no_result(self): c = conn.cursor() c.execute("create table test_nr (b varchar(32))") try: - data = "oursql" + data = "umysqldb" c.execute("insert into test_nr (b) values (%s)", (data,)) self.assertEqual(None, c.fetchone()) finally: diff --git a/tests/thirdparty/test_pymysql/test_example.py b/tests/thirdparty/test_pymysql/test_example.py index 2887118..9e8fecf 100644 --- a/tests/thirdparty/test_pymysql/test_example.py +++ b/tests/thirdparty/test_pymysql/test_example.py @@ -1,9 +1,9 @@ -import oursql +import umysqldb from . import base -class TestExample(base.OurSQLTestCase): +class TestExample(base.UMySQLdbTestCase): def test_example(self): - conn = oursql.connect(host='127.0.0.1', port=3306, user='root', passwd='', db='mysql') + conn = umysqldb.connect(host='127.0.0.1', port=3306, user='root', passwd='', db='mysql') cur = conn.cursor() diff --git a/tests/thirdparty/test_pymysql/test_issues.py b/tests/thirdparty/test_pymysql/test_issues.py index 5ccbd92..d08cb00 100644 --- a/tests/thirdparty/test_pymysql/test_issues.py +++ b/tests/thirdparty/test_pymysql/test_issues.py @@ -1,4 +1,4 @@ -import oursql +import umysqldb from . import base import unittest @@ -18,7 +18,7 @@ if not hasattr(unittest, "skip"): unittest.skip = lambda message: lambda f: f -class TestOldIssues(base.OurSQLTestCase): +class TestOldIssues(base.UMySQLdbTestCase): def test_issue_3(self): """ undefined methods datetime_or_None, date_or_None """ conn = self.connections[0] @@ -57,7 +57,7 @@ def test_issue_5(self): def test_issue_6(self): """ exception: TypeError: ord() expected a character, but string of length 0 found """ - conn = oursql.connect(host="localhost",user="root",passwd="",db="mysql") + conn = umysqldb.connect(host="localhost",user="root",passwd="",db="mysql") c = conn.cursor() c.execute("select * from user") conn.close() @@ -80,7 +80,7 @@ def test_issue_8(self): def test_issue_9(self): """ sets DeprecationWarning in Python 2.6 """ try: - reload(oursql) + reload(umysqldb) except DeprecationWarning: self.fail() @@ -146,7 +146,7 @@ def test_issue_17(self): c.execute("grant all privileges on %s.issue17 to 'issue17user'@'%%' identified by '1234'" % db) conn.commit() - conn2 = oursql.connect(host=host, user="issue17user", passwd="1234", db=db) + conn2 = umysqldb.connect(host=host, user="issue17user", passwd="1234", db=db) c2 = conn2.cursor() c2.execute("select x from issue17") self.assertEqual("hello, world!", c2.fetchone()[0]) @@ -160,18 +160,18 @@ def _uni(s, e): else: return unicode(s, e) -class TestNewIssues(base.OurSQLTestCase): +class TestNewIssues(base.UMySQLdbTestCase): def test_issue_34(self): try: - oursql.connect(host="localhost", port=1237, user="root") + umysqldb.connect(host="localhost", port=1237, user="root") self.fail() - except oursql.OperationalError, e: + except umysqldb.OperationalError, e: self.assertEqual(2003, e.args[0]) except: self.fail() def test_issue_33(self): - conn = oursql.connect(host="localhost", user="root", db=self.databases[0]["db"], charset="utf8") + conn = umysqldb.connect(host="localhost", user="root", db=self.databases[0]["db"], charset="utf8") c = conn.cursor() try: c.execute(_uni("create table hei\xc3\x9fe (name varchar(32))", "utf8")) @@ -189,7 +189,7 @@ def test_issue_35(self): try: c.execute("select sleep(10)") self.fail() - except oursql.OperationalError, e: + except umysqldb.OperationalError, e: self.assertEqual(2013, e.args[0]) def test_issue_36(self): @@ -239,7 +239,7 @@ def test_issue_38(self): finally: c.execute("drop table issue38") -class TestGitHubIssues(base.OurSQLTestCase): +class TestGitHubIssues(base.UMySQLdbTestCase): def test_issue_66(self): conn = self.connections[0] c = conn.cursor() diff --git a/oursql/__init__.py b/umysqldb/__init__.py similarity index 91% rename from oursql/__init__.py rename to umysqldb/__init__.py index 56a84a2..5490f2a 100644 --- a/oursql/__init__.py +++ b/umysqldb/__init__.py @@ -20,9 +20,9 @@ def thread_safe(): def install_as_MySQLdb(): """ After this function is called, any application that imports MySQLdb or - _mysql will unwittingly actually use oursql. + _mysql will unwittingly actually use umysqldb. """ - sys.modules["MySQLdb"] = sys.modules["_mysql"] = sys.modules["oursql"] + sys.modules["MySQLdb"] = sys.modules["_mysql"] = sys.modules["umysqldb"] sys.modules["MySQLdb.constants"] = sys.modules["pymysql.constants"] diff --git a/oursql/connections.py b/umysqldb/connections.py similarity index 94% rename from oursql/connections.py rename to umysqldb/connections.py index 4c42f4f..f74dda2 100644 --- a/oursql/connections.py +++ b/umysqldb/connections.py @@ -10,8 +10,8 @@ from .util import setdocstring from .cursors import Cursor from .err import ( - map_umysql_error_to_oursql_exception, - map_runtime_error_to_oursql_exception, + map_umysql_error_to_umysqldb_exception, + map_runtime_error_to_umysqldb_exception, Error, OperationalError, ) @@ -103,7 +103,7 @@ def _connect(self): self.host, e.args[0])) except umysql.Error, exc: traceback = sys.exc_info()[2] - exc = map_umysql_error_to_oursql_exception(exc) + exc = map_umysql_error_to_umysqldb_exception(exc) raise exc, None, traceback # internal use only (called from cursor) @@ -113,11 +113,11 @@ def query(self, sql, args=()): result_set = self._umysql_conn.query(sql, args) except umysql.Error, exc: traceback = sys.exc_info()[2] - exc = map_umysql_error_to_oursql_exception(exc) + exc = map_umysql_error_to_umysqldb_exception(exc) raise exc, None, traceback except RuntimeError, exc: traceback = sys.exc_info()[2] - exc = map_runtime_error_to_oursql_exception(exc) + exc = map_runtime_error_to_umysqldb_exception(exc) raise exc, None, traceback else: self._result = self._convert_result_set(result_set) diff --git a/oursql/cursors.py b/umysqldb/cursors.py similarity index 100% rename from oursql/cursors.py rename to umysqldb/cursors.py diff --git a/oursql/err.py b/umysqldb/err.py similarity index 83% rename from oursql/err.py rename to umysqldb/err.py index 443c345..0587e45 100644 --- a/oursql/err.py +++ b/umysqldb/err.py @@ -1,6 +1,6 @@ from pymysql.err import * -def map_umysql_error_to_oursql_exception(umysql_exc): +def map_umysql_error_to_umysqldb_exception(umysql_exc): errorclass = error_map.get(umysql_exc.args[0]) if errorclass: return errorclass(*umysql_exc.args) @@ -12,7 +12,7 @@ def map_umysql_error_to_oursql_exception(umysql_exc): return InternalError(*umysql_exc.args) -def map_runtime_error_to_oursql_exception(exc): +def map_runtime_error_to_umysqldb_exception(exc): if exc.args == ('Not connected',): return ProgrammingError("cursor closed") return exc diff --git a/oursql/times.py b/umysqldb/times.py similarity index 100% rename from oursql/times.py rename to umysqldb/times.py diff --git a/oursql/util.py b/umysqldb/util.py similarity index 100% rename from oursql/util.py rename to umysqldb/util.py