From 37421991b446f2077a9fb4e9a6d580b1c08044a3 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 20 May 2015 06:37:11 -0700 Subject: [PATCH] optional pymysql support This allows you to specify MYSQL_DRIVER=PyMySQL and get it in the environment. Change-Id: Ic9d75266640b7aa6d7efb6e882d3027e81414059 --- files/venv-requirements.txt | 1 - lib/databases/mysql | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/files/venv-requirements.txt b/files/venv-requirements.txt index 73d05793ce..b9a55b423d 100644 --- a/files/venv-requirements.txt +++ b/files/venv-requirements.txt @@ -1,7 +1,6 @@ # Once we can prebuild wheels before a devstack run, uncomment the skipped libraries cryptography # lxml # still install from from packages -MySQL-python # netifaces # still install from packages #numpy # slowest wheel by far, stop building until we are actually using the output posix-ipc diff --git a/lib/databases/mysql b/lib/databases/mysql index 1b9a08199f..7cd2856ae9 100644 --- a/lib/databases/mysql +++ b/lib/databases/mysql @@ -11,6 +11,13 @@ MY_XTRACE=$(set +o | grep xtrace) set +o xtrace +MYSQL_DRIVER=${MYSQL_DRIVER:-MySQL-python} +# Force over to pymysql driver by default if we are using it. +if is_service_enabled mysql; then + if [[ "$MYSQL_DRIVER" == "PyMySQL" ]]; then + SQLALCHEMY_DATABASE_DRIVER=${SQLALCHEMY_DATABASE_DRIVER:-"pymysql"} + fi +fi register_database mysql @@ -155,8 +162,10 @@ EOF function install_database_python_mysql { # Install Python client module - pip_install_gr MySQL-python - ADDITIONAL_VENV_PACKAGES+=",MySQL-python" + pip_install_gr $MYSQL_DRIVER + if [[ "$MYSQL_DRIVER" == "MySQL-python" ]]; then + ADDITIONAL_VENV_PACKAGES+=",MySQL-python" + fi } function database_connection_url_mysql {