def delete_session(session_year):
 tables = {'bill_id': ['bill_detail_vote_tbl', 'bill_history_tbl', 'bill_summary_vote_tbl', 'bill_analysis_tbl', 'bill_tbl', 'committee_hearing_tbl', 'daily_file_tbl'], 'bill_version_id': ['bill_version_authors_tbl', 'bill_version_tbl'], 'session_year': ['legislator_tbl', 'location_code_tbl']}
 logger.info(('Deleting all data for session year %s...' % session_year))
 connection = MySQLdb.connect(user=MYSQL_USER, passwd=MYSQL_PASSWORD, db='capublic')
 connection.autocommit(True)
 cursor = connection.cursor()
 for (token, names) in tables.items():
  for table_name in names:
   sql = "DELETE FROM capublic.{table_name} where {token} like '{session_year}%';"
   sql = sql.format(**locals())
   logger.debug(('executing sql: "%s"' % sql))
   cursor.execute(sql)
 cursor.close()
 connection.close()
 logger.info('...done deleting session data.')

def delete_session ( session_year ) : tables = { 'bill_id' : [ 'bill_detail_vote_tbl' , 'bill_history_tbl' , 'bill_summary_vote_tbl' , 'bill_analysis_tbl' , 'bill_tbl' , 'committee_hearing_tbl' , 'daily_file_tbl' ] , 'bill_version_id' : [ 'bill_version_authors_tbl' , 'bill_version_tbl' ] , 'session_year' : [ 'legislator_tbl' , 'location_code_tbl' ] } logger . info ( ( 'Deleting all data for session year %s...' % session_year ) ) connection = MySQLdb . connect ( user = MYSQL_USER , passwd = MYSQL_PASSWORD , db = 'capublic' ) connection . autocommit ( True ) cursor = connection . cursor ( ) for ( token , names ) in tables . items ( ) : for table_name in names : sql = "DELETE FROM capublic.{table_name} where {token} like '{session_year}%';" sql = sql . format ( ** locals ( ) ) logger . debug ( ( 'executing sql: "%s"' % sql ) ) cursor . execute ( sql ) cursor . close ( ) connection . close ( ) logger . info ( '...done deleting session data.' )
this is the python equivalent of the deletesession .