Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MYSQL and PyMySql question: ( Sample solution format is provided at the very end for a similar type of question) from dbconfig import * import
MYSQL and PyMySql question: ( Sample solution format is provided at the very end for a similar type of question)
from dbconfig import * import pymysql import sys, getopt db = get_mysql_param() cnx = pymysql.connect(user=db['user'], password=db['password'], host=db['host'], database=db['database']) cursor = cnx.cursor() query = ''' select distinct e.Title, count(distinct p.SwimmerId) as numSwimmers, group_concat(concat(s.fname, ' ', s.lname, if(p.comment is null, '', concat(': ', p.comment))) order by s.lname, s.fname separator '; ') as result from Event e, Participation p, Swimmer s where e.EventId = p.EventId and p.SwimmerId = s.SwimmerId and e.MeetId = %s group by e.Title; ''' meetId = sys.argv[1] cursor.execute(query, (meetId,)) print('Events in Meet #' + meetId) print('------------------') for (event, nSwimmers, result) in cursor: print(' ' + event + ': ' + str(nSwimmers) + ' swimmers> ' + result) cursor.close() cnx.close()(2) Use CLYSTMS in MySQL: sreateCLYSTMSDE.sqlet and PopulateCLYSTMS.Sqltxt Write a Python program, h7.py to list all swimmers with caretaker id ct id in the following manner. Note that the swimmer names, whether ct id is a primary or other caretaker, and the numbers of events the swimmers participated in are shown. Note that ct ld is input as a command line argument and you may assume that there will be no input error. For example: python h7.py 1 swinner under care car taler *1 Billy han (aa prinary caretaker)> partiolpated in d eventa Bobby Ehan (as prinary carotakez)> participatod in4 ovents nina nan a other cartalcor > participated in 4 event Please pay attention to details. Your program should import dbconfig.py (copy below and save it in the file name in the same directory): inport configparser # 5molistic and no error handling def got ml paran(filenm-dooonfig.ini", sectin-maq') config -configparer.ConfigPaxsex) oonfig.road (filonama roturn config!nysql' which in turn reads the dbconfig.ini file: nysq11 host lecalhost database = c1ystma user-youraccountname>> (2) Use CLYSTMS in MySQL: sreateCLYSTMSDE.sqlet and PopulateCLYSTMS.Sqltxt Write a Python program, h7.py to list all swimmers with caretaker id ct id in the following manner. Note that the swimmer names, whether ct id is a primary or other caretaker, and the numbers of events the swimmers participated in are shown. Note that ct ld is input as a command line argument and you may assume that there will be no input error. For example: python h7.py 1 swinner under care car taler *1 Billy han (aa prinary caretaker)> partiolpated in d eventa Bobby Ehan (as prinary carotakez)> participatod in4 ovents nina nan a other cartalcor > participated in 4 event Please pay attention to details. Your program should import dbconfig.py (copy below and save it in the file name in the same directory): inport configparser # 5molistic and no error handling def got ml paran(filenm-dooonfig.ini", sectin-maq') config -configparer.ConfigPaxsex) oonfig.road (filonama roturn config!nysql' which in turn reads the dbconfig.ini file: nysq11 host lecalhost database = c1ystma user-youraccountname>>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started