Skip to content

Instantly share code, notes, and snippets.

@twangboy
Created August 31, 2015 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twangboy/b8122cbde4605240121f to your computer and use it in GitHub Desktop.
Save twangboy/b8122cbde4605240121f to your computer and use it in GitHub Desktop.
# Import third party libs
try:
# Try to import MySQLdb
import MySQLdb
HAS_MYSQLDB = True
except ImportError:
try:
# MySQLdb import failed, try to import PyMySQL
import pymysql
pymysql.install_as_MySQLdb()
import MySQLdb
HAS_MYSQLDB = True
except ImportError:
# No MySQL Connector installed, return False
HAS_MYSQLDB = False
import MySQLdb.cursors
import MySQLdb.converters
from MySQLdb.constants import FIELD_TYPE, FLAG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment