Compare commits

...

1 Commits

Author SHA1 Message Date
Jonathan Ervine
2d0be883da Remove commented out MySqlDB commands 2021-09-20 07:15:44 +08:00
2 changed files with 1 additions and 16 deletions

View File

@ -21,6 +21,7 @@ libraries:
env_variables:
CLOUDSQL_CONNECTION_NAME: hk-hockey:asia-east2:hk-hockey-sql
LOCAL_DB_SERVER: mariadb.db.svc.cluster.local
CLOUDSQL_USER: root
CLOUDSQL_WRITE_USER: hockeyWrite
CLOUDSQL_READ_USER: hockeyRead

View File

@ -26,8 +26,6 @@ def write_cloudsql():
# Connect using the unix socket located at
# /cloudsql/cloudsql-connection-name.
cloudsql_unix_socket = os.path.join('/cloudsql', CLOUDSQL_CONNECTION_NAME)
# db = MySQLdb.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
# If the unix socket is unavailable, then try to connect using TCP. This
@ -37,7 +35,6 @@ def write_cloudsql():
# $ cloud_sql_proxy -instances=your-connection-name=tcp:3306
#
else:
# db = MySQLdb.connect(host='db.ipa.champion', user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(host=LOCAL_DB_SERVER, user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=LOCAL_DATABASE, charset=CLOUDSQL_CHARSET)
return db
@ -48,8 +45,6 @@ def write_cloudsql_static():
# Connect using the unix socket located at
# /cloudsql/cloudsql-connection-name.
cloudsql_unix_socket = os.path.join('/cloudsql', CLOUDSQL_CONNECTION_NAME)
# db = MySQLdb.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
# If the unix socket is unavailable, then try to connect using TCP. This
@ -59,7 +54,6 @@ def write_cloudsql_static():
# $ cloud_sql_proxy -instances=your-connection-name=tcp:3306
#
else:
# db = MySQLdb.connect(host='db.ipa.champion', user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(host=LOCAL_DB_SERVER, user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
return db
@ -70,8 +64,6 @@ def read_cloudsql():
# Connect using the unix socket located at
# /cloudsql/cloudsql-connection-name.
cloudsql_unix_socket = os.path.join('/cloudsql', CLOUDSQL_CONNECTION_NAME)
# db = MySQLdb.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
# If the unix socket is unavailable, then try to connect using TCP. This
@ -81,7 +73,6 @@ def read_cloudsql():
# $ cloud_sql_proxy -instances=your-connection-name=tcp:3306
#
else:
# db = MySQLdb.connect(host='db.ipa.champion', user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(host=LOCAL_DB_SERVER, user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=LOCAL_DATABASE, charset=CLOUDSQL_CHARSET)
return db
@ -92,8 +83,6 @@ def read_cloudsql_static():
# Connect using the unix socket located at
# /cloudsql/cloudsql-connection-name.
cloudsql_unix_socket = os.path.join('/cloudsql', CLOUDSQL_CONNECTION_NAME)
# db = MySQLdb.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(unix_socket=cloudsql_unix_socket, user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
# If the unix socket is unavailable, then try to connect using TCP. This
@ -103,14 +92,12 @@ def read_cloudsql_static():
# $ cloud_sql_proxy -instances=your-connection-name=tcp:3306
#
else:
# db = MySQLdb.connect(host='db.ipa.champion', user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
db = pymysql.connect(host=LOCAL_DB_SERVER, user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=CLOUDSQL_DATABASE_STATIC, charset=CLOUDSQL_CHARSET)
return db
def sql_write(sql_cmd):
try:
db = write_cloudsql()
# cursor = db.cursor(MySQLdb.cursors.DictCursor)
cursor = db.cursor(pymysql.cursors.DictCursor)
cursor.execute(sql_cmd)
db.commit()
@ -124,7 +111,6 @@ def sql_write(sql_cmd):
def sql_write_static(sql_cmd):
try:
db = write_cloudsql_static()
# cursor = db.cursor(MySQLdb.cursors.DictCursor)
cursor = db.cursor(pymysql.cursors.DictCursor)
cursor.execute(sql_cmd)
db.commit()
@ -138,7 +124,6 @@ def sql_write_static(sql_cmd):
def sql_read(sql_cmd):
try:
db = read_cloudsql()
# cursor = db.cursor(MySQLdb.cursors.DictCursor)
cursor = db.cursor(pymysql.cursors.DictCursor)
cursor.execute(sql_cmd)
rows = cursor.fetchall()
@ -153,7 +138,6 @@ def sql_read(sql_cmd):
def sql_read_static(sql_cmd):
try:
db = read_cloudsql_static()
# cursor = db.cursor(MySQLdb.cursors.DictCursor)
cursor = db.cursor(pymysql.cursors.DictCursor)
cursor.execute(sql_cmd)
rows = cursor.fetchall()