Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
rename oursql to umysqldb, as oursql is already taken in pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
hongqn committed Apr 24, 2012
1 parent c3fc693 commit af0e6ce
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 62 deletions.
10 changes: 10 additions & 0 deletions 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
4 changes: 2 additions & 2 deletions setup.py
@@ -1,14 +1,14 @@
import os
from setuptools import setup, find_packages
from oursql import __version__
from umysqldb import __version__

install_requires = [
'umysql',
'pymysql',
]

setup(
name = 'oursql',
name = 'umysqldb',
description = "MySQLdb compatible wrapper for ultramysql",
long_description = open(os.path.join(os.path.dirname(__file__),
'README.rst')).read(),
Expand Down
6 changes: 3 additions & 3 deletions tests/__init__.py
Expand Up @@ -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


6 changes: 3 additions & 3 deletions 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')
8 changes: 4 additions & 4 deletions 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',
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions tests/thirdparty/test_MySQLdb/test_oursql_dbapi20.py
Expand Up @@ -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',
Expand Down
16 changes: 8 additions & 8 deletions 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):
Expand Down Expand Up @@ -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):
Expand Down
10 changes: 5 additions & 5 deletions 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:
Expand Down
6 changes: 3 additions & 3 deletions 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"),
Expand Down
6 changes: 3 additions & 3 deletions 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
Expand All @@ -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 ('
Expand Down
10 changes: 5 additions & 5 deletions tests/thirdparty/test_pymysql/test_basic.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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])
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions 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()
Expand Down
22 changes: 11 additions & 11 deletions tests/thirdparty/test_pymysql/test_issues.py
@@ -1,4 +1,4 @@
import oursql
import umysqldb
from . import base
import unittest

Expand All @@ -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]
Expand Down Expand Up @@ -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()
Expand All @@ -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()

Expand Down Expand Up @@ -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])
Expand All @@ -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"))
Expand All @@ -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):
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions oursql/__init__.py → umysqldb/__init__.py
Expand Up @@ -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"]


Expand Down
10 changes: 5 additions & 5 deletions oursql/connections.py → umysqldb/connections.py
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
File renamed without changes.

0 comments on commit af0e6ce

Please sign in to comment.