Switch from mysql-python to PyMySQL
mysql-python undesireable over PyMySQL for a few reasons. Mainly, it does not support Py3* and does not work well with eventlet. There is also a bug in using oslo.db with PyMySQL where reference errors are not properly detected. This fixed in oslo.db ab20754db71e55b79b9e71e36ad86d9befc89a92 but we should still work around this unless global-requirements are bumped for oslo.db. Also adding pymysql to requirements since it is a pure python library and having a codebase that can 'just work' is awesome. Change-Id: I0058193c7cbd329731ade37108614fa6eb19d0f7
This commit is contained in:
parent
110081865c
commit
ac0f86858d
@ -110,7 +110,7 @@ lock_path = $state_path/lock
|
|||||||
[database]
|
[database]
|
||||||
# This line MUST be changed to actually run storyboard
|
# This line MUST be changed to actually run storyboard
|
||||||
# Example:
|
# Example:
|
||||||
# connection = mysql://root:pass@127.0.0.1:3306/storyboard
|
# connection = mysql+pymysql://root:pass@127.0.0.1:3306/storyboard
|
||||||
# Replace 127.0.0.1 above with the IP address of the database used by the
|
# Replace 127.0.0.1 above with the IP address of the database used by the
|
||||||
# main storyboard server. (Leave it as is if the database runs on this host.)
|
# main storyboard server. (Leave it as is if the database runs on this host.)
|
||||||
# connection=sqlite://
|
# connection=sqlite://
|
||||||
|
@ -26,3 +26,4 @@ python-crontab>=1.8.1
|
|||||||
tzlocal>=1.1.2
|
tzlocal>=1.1.2
|
||||||
rfc3987>=1.3.4
|
rfc3987>=1.3.4
|
||||||
Jinja2>=2.7.3
|
Jinja2>=2.7.3
|
||||||
|
PyMySQL>=0.6.2
|
||||||
|
@ -27,3 +27,4 @@ tzlocal>=1.1.2
|
|||||||
rfc3987>=1.3.4
|
rfc3987>=1.3.4
|
||||||
email>=4.0.2
|
email>=4.0.2
|
||||||
Jinja2>=2.7.3
|
Jinja2>=2.7.3
|
||||||
|
PyMySQL>=0.6.2
|
||||||
|
@ -266,9 +266,6 @@ def entity_create(kls, values):
|
|||||||
except db_exc.DBDuplicateEntry as de:
|
except db_exc.DBDuplicateEntry as de:
|
||||||
raise exc.DBDuplicateEntry(object_name=kls.__name__,
|
raise exc.DBDuplicateEntry(object_name=kls.__name__,
|
||||||
value=de.value)
|
value=de.value)
|
||||||
except db_exc.DBReferenceError as re:
|
|
||||||
raise exc.DBReferenceError(object_name=kls.__name__,
|
|
||||||
value=re.constraint, key=re.key)
|
|
||||||
except db_exc.DBConnectionError:
|
except db_exc.DBConnectionError:
|
||||||
raise exc.DBConnectionError()
|
raise exc.DBConnectionError()
|
||||||
except db_exc.ColumnError:
|
except db_exc.ColumnError:
|
||||||
@ -277,6 +274,11 @@ def entity_create(kls, values):
|
|||||||
raise exc.DBDeadLock()
|
raise exc.DBDeadLock()
|
||||||
except db_exc.DBInvalidUnicodeParameter:
|
except db_exc.DBInvalidUnicodeParameter:
|
||||||
raise exc.DBInvalidUnicodeParameter
|
raise exc.DBInvalidUnicodeParameter
|
||||||
|
# XXX(greghaynes) Due to a bug in oslo.db + PyMySQL reference errors
|
||||||
|
# are not properly raised.
|
||||||
|
except db_exc.DBError:
|
||||||
|
raise exc.DBReferenceError(object_name=kls.__name__,
|
||||||
|
value='unknown', key='unknown')
|
||||||
|
|
||||||
return entity
|
return entity
|
||||||
|
|
||||||
@ -299,9 +301,6 @@ def entity_update(kls, entity_id, values):
|
|||||||
except db_exc.DBDuplicateEntry as de:
|
except db_exc.DBDuplicateEntry as de:
|
||||||
raise exc.DBDuplicateEntry(object_name=kls.__name__,
|
raise exc.DBDuplicateEntry(object_name=kls.__name__,
|
||||||
value=de.value)
|
value=de.value)
|
||||||
except db_exc.DBReferenceError as re:
|
|
||||||
raise exc.DBReferenceError(object_name=kls.__name__,
|
|
||||||
value=re.constraint, key=re.key)
|
|
||||||
except db_exc.DBConnectionError:
|
except db_exc.DBConnectionError:
|
||||||
raise exc.DBConnectionError()
|
raise exc.DBConnectionError()
|
||||||
except db_exc.ColumnError:
|
except db_exc.ColumnError:
|
||||||
@ -310,6 +309,11 @@ def entity_update(kls, entity_id, values):
|
|||||||
raise exc.DBDeadLock()
|
raise exc.DBDeadLock()
|
||||||
except db_exc.DBInvalidUnicodeParameter:
|
except db_exc.DBInvalidUnicodeParameter:
|
||||||
raise exc.DBInvalidUnicodeParameter
|
raise exc.DBInvalidUnicodeParameter
|
||||||
|
# XXX(greghaynes) Due to a bug in oslo.db + PyMySQL reference errors
|
||||||
|
# are not properly raised.
|
||||||
|
except db_exc.DBError:
|
||||||
|
raise exc.DBReferenceError(object_name=kls.__name__,
|
||||||
|
value='error', key='error')
|
||||||
|
|
||||||
session = get_session()
|
session = get_session()
|
||||||
entity = __entity_get(kls, entity_id, session)
|
entity = __entity_get(kls, entity_id, session)
|
||||||
@ -330,9 +334,6 @@ def entity_hard_delete(kls, entity_id):
|
|||||||
|
|
||||||
session.delete(entity)
|
session.delete(entity)
|
||||||
|
|
||||||
except db_exc.DBReferenceError as re:
|
|
||||||
raise exc.DBReferenceError(object_name=kls.__name__,
|
|
||||||
value=re.constraint, key=re.key)
|
|
||||||
except db_exc.DBConnectionError:
|
except db_exc.DBConnectionError:
|
||||||
raise exc.DBConnectionError()
|
raise exc.DBConnectionError()
|
||||||
except db_exc.ColumnError:
|
except db_exc.ColumnError:
|
||||||
@ -341,3 +342,8 @@ def entity_hard_delete(kls, entity_id):
|
|||||||
raise exc.DBDeadLock()
|
raise exc.DBDeadLock()
|
||||||
except db_exc.DBInvalidUnicodeParameter:
|
except db_exc.DBInvalidUnicodeParameter:
|
||||||
raise exc.DBInvalidUnicodeParameter()
|
raise exc.DBInvalidUnicodeParameter()
|
||||||
|
# XXX(greghaynes) Due to a bug in oslo.db + PyMySQL reference errors
|
||||||
|
# are not properly raised.
|
||||||
|
except db_exc.DBError:
|
||||||
|
raise exc.DBReferenceError(object_name=kls.__name__,
|
||||||
|
value='unkonwn', key='unknonwn')
|
||||||
|
@ -69,8 +69,8 @@ class TestCase(testtools.TestCase):
|
|||||||
if env_test_db is not None:
|
if env_test_db is not None:
|
||||||
self.test_connection = env_test_db
|
self.test_connection = env_test_db
|
||||||
else:
|
else:
|
||||||
self.test_connection = ("mysql://openstack_citest:openstack_citest"
|
self.test_connection = ("mysql+pymysql://openstack_citest:"
|
||||||
"@127.0.0.1:3306")
|
"openstack_citest@127.0.0.1:3306")
|
||||||
|
|
||||||
self.useFixture(fixtures.NestedTempfile())
|
self.useFixture(fixtures.NestedTempfile())
|
||||||
self.useFixture(fixtures.TempHomeDir())
|
self.useFixture(fixtures.TempHomeDir())
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#sqlite=sqlite://
|
#sqlite=sqlite://
|
||||||
#sqlitefile=sqlite:///test_migrations_utils.db
|
#sqlitefile=sqlite:///test_migrations_utils.db
|
||||||
mysql=mysql+mysqldb://storyboard:storyboard@localhost/test_migrations_utils
|
mysql=mysql+pymysql://storyboard:storyboard@localhost/test_migrations_utils
|
||||||
|
|
||||||
[migration_dbs]
|
[migration_dbs]
|
||||||
# Migration DB details are listed separately as they can't be connected to
|
# Migration DB details are listed separately as they can't be connected to
|
||||||
@ -17,7 +17,7 @@ mysql=mysql+mysqldb://storyboard:storyboard@localhost/test_migrations_utils
|
|||||||
|
|
||||||
#sqlite=sqlite://
|
#sqlite=sqlite://
|
||||||
#sqlitefile=sqlite:///test_migrations.db
|
#sqlitefile=sqlite:///test_migrations.db
|
||||||
#mysql=mysql+mysqldb://user:pass@localhost/test_migrations
|
#mysql=mysql+pymysql://user:pass@localhost/test_migrations
|
||||||
|
|
||||||
[walk_style]
|
[walk_style]
|
||||||
snake_walk=yes
|
snake_walk=yes
|
||||||
|
@ -53,7 +53,7 @@ def _get_connect_string(backend, user, passwd, database):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if backend == "mysql":
|
if backend == "mysql":
|
||||||
backend = "mysql+mysqldb"
|
backend = "mysql+pymysql"
|
||||||
else:
|
else:
|
||||||
raise Exception("Unrecognized backend: '%s'" % backend)
|
raise Exception("Unrecognized backend: '%s'" % backend)
|
||||||
|
|
||||||
|
@ -14,9 +14,6 @@ testtools>=0.9.34
|
|||||||
posix_ipc>=0.9.8
|
posix_ipc>=0.9.8
|
||||||
|
|
||||||
|
|
||||||
# Some of the tests use real MySQL and Postgres databases
|
|
||||||
MySQL-python
|
|
||||||
|
|
||||||
# Doc requirements
|
# Doc requirements
|
||||||
sphinx>=1.1.2,<1.2
|
sphinx>=1.1.2,<1.2
|
||||||
sphinxcontrib-pecanwsme>=0.5
|
sphinxcontrib-pecanwsme>=0.5
|
||||||
|
Loading…
Reference in New Issue
Block a user