Created
February 17, 2014 17:38
-
-
Save abemusic/9055332 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load the default settings | |
from django.conf import settings | |
settings.configure() | |
from django.db.utils import load_backend | |
from dj_database_url import parse | |
def try_dsn(dsn): | |
try: | |
db = parse(dsn) | |
db['OPTIONS'] = {} | |
mod = load_backend('django.db.backends.mysql') | |
wrapper = mod.DatabaseWrapper(db) | |
wrapper.cursor() | |
except Exception, e: | |
print e.args[1] | |
return | |
print 'SUCCESS!' | |
if __name__ == '__main__': | |
try_dsn('mysql://foo:bar@localhost:3306/dbname') | |
try_dsn('mysql://gooduser:password@localhost:3306/good_db') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment