Skip to content

Instantly share code, notes, and snippets.

@githubutilities
Last active November 13, 2015 06:02
Show Gist options
  • Select an option

  • Save githubutilities/042f0e6189128fc637ab to your computer and use it in GitHub Desktop.

Select an option

Save githubutilities/042f0e6189128fc637ab to your computer and use it in GitHub Desktop.
SAE MySQL

SAE MySQL

SAE sql import

Current SAE MySQL uses MySQL version 5.5, so sql script exported by MySQL version 5.6 may not works when imported into SAE MySQL service. My solutions is following:

# unlink current version of mysql
brew unlink mysql

# install mysql v5.5
# first, tap homebrew-version
brew tap homebrew/version
brew install mysql55
# --force parameter is for causion of messing up with current version of mysql
brew link mysql55 --force

# exporting sql script
mysqldump -uroot database-name > out.sql
# you should remove ALL `LOCK` and `UNLOCK` statement from `out.sql`
# now you can import your sql script into SAE MySQL

SAE MySQL connection for Django

Add following config to your project settings.py

DEPLOYED = True
try:
    import sae.const
except ImportError:
    DEPLOYED = False

if not DEPLOYED:
    MYSQL_DB = 'database-name'
    MYSQL_USER = 'root'
    MYSQL_PASS = ''
    MYSQL_HOST_M = 'localhost'
    MYSQL_HOST_S = 'localhost'
    MYSQL_PORT = '3306'
else:
    MYSQL_DB = sae.const.MYSQL_DB
    MYSQL_USER = sae.const.MYSQL_USER
    MYSQL_PASS = sae.const.MYSQL_PASS
    MYSQL_HOST_M = sae.const.MYSQL_HOST
    MYSQL_HOST_S = sae.const.MYSQL_HOST_S
    MYSQL_PORT = sae.const.MYSQL_PORT

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': MYSQL_DB,
        'USER': MYSQL_USER,
        'PASSWORD': MYSQL_PASS,
        'HOST': MYSQL_HOST_M,
        'PORT': MYSQL_PORT,
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment