Skip to content
Snippets Groups Projects
Commit fc77345c authored by Julian Rother's avatar Julian Rother
Browse files

Enabled unix domain socket support for mysql

parent dab1545c
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,8 @@ DB_DATA = 'db_example.sql' ...@@ -11,7 +11,8 @@ DB_DATA = 'db_example.sql'
#DB_ENGINE = 'mysql' #DB_ENGINE = 'mysql'
#MYSQL_HOST = 'localhost' #MYSQL_HOST = 'localhost'
#MYSQL_USER = 'videoag' #MYSQL_USER = 'videoag'
MYSQL_PORT = 3306 #MYSQL_PORT = 3306
#MYSQL_UNIX = '/var/run/mysqld/mysqld.sock'
#MYSQL_PASSWD = 'somuchsecret' #MYSQL_PASSWD = 'somuchsecret'
#MYSQL_DB = 'videos' #MYSQL_DB = 'videos'
......
...@@ -47,7 +47,7 @@ elif config['DB_ENGINE'] == 'mysql': ...@@ -47,7 +47,7 @@ elif config['DB_ENGINE'] == 'mysql':
def get_dbcursor(): def get_dbcursor():
if 'db' not in g or not g.db.is_connected(): if 'db' not in g or not g.db.is_connected():
g.db = mysql.connector.connect(user=config['MYSQL_USER'], password=config['MYSQL_PASSWD'], host=config['MYSQL_HOST'], port=config['MYSQL_PORT'], database=config['MYSQL_DB']) g.db = mysql.connector.connect(user=config['MYSQL_USER'], password=config['MYSQL_PASSWD'], host=config.get('MYSQL_HOST', None), port=config.get('MYSQL_PORT', 3306), unix_socket=config.get('MYSQL_UNIX', None), database=config['MYSQL_DB'])
if not hasattr(request, 'db'): if not hasattr(request, 'db'):
request.db = g.db.cursor() request.db = g.db.cursor()
return request.db return request.db
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment