Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d0be883da | ||
|
|
c0d01cca3f | ||
|
|
58d39a464d | ||
|
|
3d21364152 | ||
|
|
e7f914e503 | ||
|
|
a368826ce4 | ||
|
|
83a427c712 | ||
|
|
43561c926a | ||
|
|
c1ecfecbac |
@@ -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
|
||||
|
||||
+6
-21
@@ -6,6 +6,7 @@ import json
|
||||
# These environment variables are configured in app.yaml.
|
||||
|
||||
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"
|
||||
@@ -13,7 +14,7 @@ CLOUDSQL_PASSWORD = "P8P1YopMlwg8TxhE"
|
||||
CLOUDSQL_WRITE_PASSWORD = "1URYcxXXlQ6xOWgj"
|
||||
CLOUDSQL_READ_PASSWORD = "o4GWrbbkBKy3oR6u"
|
||||
CLOUDSQL_DATABASE = "20209_hockeyResults"
|
||||
LOCAL_DATABASE = "hockeyResults2020"
|
||||
LOCAL_DATABASE = "hockeyResults2021"
|
||||
CLOUDSQL_DATABASE_STATIC = "hockeyResults"
|
||||
CLOUDSQL_CHARSET = "utf8"
|
||||
|
||||
@@ -25,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
|
||||
@@ -36,8 +35,7 @@ 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='db.ipa.champion', user=CLOUDSQL_WRITE_USER, passwd=CLOUDSQL_WRITE_PASSWORD, db=LOCAL_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
|
||||
|
||||
def write_cloudsql_static():
|
||||
@@ -47,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
|
||||
@@ -58,8 +54,7 @@ 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='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
|
||||
|
||||
def read_cloudsql():
|
||||
@@ -69,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
|
||||
@@ -80,8 +73,7 @@ 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='db.ipa.champion', user=CLOUDSQL_READ_USER, passwd=CLOUDSQL_READ_PASSWORD, db=LOCAL_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
|
||||
|
||||
def read_cloudsql_static():
|
||||
@@ -91,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
|
||||
@@ -102,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='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()
|
||||
@@ -123,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()
|
||||
@@ -137,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()
|
||||
@@ -152,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()
|
||||
|
||||
@@ -54,7 +54,7 @@ class playerDbCreateForm(FlaskForm):
|
||||
|
||||
class searchForm(FlaskForm):
|
||||
seasonStart = datetime.strptime('2018-09-01', '%Y-%m-%d')
|
||||
season = SelectField('Season data to search', choices=[('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')])
|
||||
season = SelectField('Season data to search', choices=[('2021', '2021/22'), ('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')])
|
||||
clubName = SelectField("Club to search", choices=[], coerce=str)
|
||||
teamName = SelectField("Select a Team", choices=[])
|
||||
startDate = DateField('DatePicker', format='%Y-%m-%d', default=seasonStart)
|
||||
@@ -62,19 +62,19 @@ class searchForm(FlaskForm):
|
||||
submitButton = SubmitField("Submit")
|
||||
|
||||
class playerRecordsForm(FlaskForm):
|
||||
season = SelectField('Season data to search', choices=[('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')])
|
||||
season = SelectField('Season data to search', choices=[('2021', '2021/22'), ('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')])
|
||||
clubName = SelectField("Club to search", choices=[], coerce=str)
|
||||
teamName = SelectField("Select a Team", choices=[])
|
||||
submitButton = SubmitField("Submit")
|
||||
|
||||
class teamRecordsForm(FlaskForm):
|
||||
season = SelectField('Season data to search', choices=[('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')])
|
||||
season = SelectField('Season data to search', choices=[('2021', '2021/22'), ('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')])
|
||||
clubName = SelectField("Club to search", choices=[], coerce=str)
|
||||
teamName = SelectField("Select a Team", choices=[])
|
||||
submitButton = SubmitField("Submit")
|
||||
|
||||
class clubPlayingRecordsForm(FlaskForm):
|
||||
season = SelectField('Season data to search', choices=[('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')])
|
||||
season = SelectField('Season data to search', choices=[('2021', '2021/22'), ('2020', '2020/21'), ('2019', '2019/20'), ('2018', '2018/19'), ('2017', '2017/18'), ('2016', '2016/17'), ('2015', '2015/16'), ('2014', '2014/15'), ('2013', '2013/14')])
|
||||
clubName = SelectField("Club to search", choices=[], coerce=str)
|
||||
submitButton = SubmitField("Submit")
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ def hkfcD_motm_vote(randomUrlSuffix):
|
||||
currMotM = nextInfo[0]['currMotM']
|
||||
currDotD = nextInfo[0]['currDotD']
|
||||
oppo = nextTeam
|
||||
sql3 = "SELECT hockeyResults2020.hockeyFixtures.date, hockeyResults.hkfcDAdminSettings.nextFixture FROM hockeyResults2020.hockeyFixtures INNER JOIN hockeyResults.hkfcDAdminSettings ON hockeyResults2020.hockeyFixtures.fixtureNumber = hockeyResults.hkfcDAdminSettings.nextFixture"
|
||||
sql3 = "SELECT hockeyResults2021.hockeyFixtures.date, hockeyResults.hkfcDAdminSettings.nextFixture FROM hockeyResults2021.hockeyFixtures INNER JOIN hockeyResults.hkfcDAdminSettings ON hockeyResults2021.hockeyFixtures.fixtureNumber = hockeyResults.hkfcDAdminSettings.nextFixture"
|
||||
nextMatchDate = sql_read(sql3)
|
||||
nextDate = nextMatchDate[0]['date']
|
||||
formatDate = datetime.strftime(nextDate, '%A, %d %B %Y')
|
||||
@@ -148,7 +148,7 @@ def hkfcDMotmAdmin():
|
||||
currSuffix = tempSuffix[0]['motmUrlSuffix']
|
||||
print(currSuffix)
|
||||
flash('Man of the Match vote is now activated')
|
||||
flash('MotM URL https://hk-hockey.appspot.com/hkfc-d/motm/'+currSuffix)
|
||||
flash('MotM URL https://hockey.ppspone.cloud/hkfc-d/motm/'+currSuffix)
|
||||
else:
|
||||
flash('Something went wrong - check with Smithers')
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<doctype html>
|
||||
<head>
|
||||
<title>Fixture List 2020/21 season</title>
|
||||
<title>Fixture List 2021/22 season</title>
|
||||
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
|
||||
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
|
||||
|
||||
Reference in New Issue
Block a user