code: # -*- coding: utf8 -*-
  import pandas as pd
  import pymysql
  
  # import configuration in parent dir
  import os, sys, inspect
  
  current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
  parent_dir = os.path.dirname(current_dir)
  sys.path.insert(0, parent_dir)
  import configuration as conf
  # import packages in models
  from models import data_processing, database_management, file_management
  
  
  if __name__ == '__main__':
  
      # change working directory to project location
      abspath = os.path.abspath(__file__)
      dname = os.path.dirname(os.path.dirname(abspath))
      os.chdir(dname)
  
      # script parameters
      name_to_update = sys.argv[1]
      update_type = sys.argv[2]
      update_method = sys.argv[3]
      update_point = sys.argv[4]
  
      # start updating database content
  
      # log in database
      config = conf.auto_log_in("cardo_main")
      conn = pymysql.connect(**config)
      conn_cursor = conn.cursor()
  
      # set up parameters for update
      column_to_update = ""
      if update_type == "0":
          column_to_update = "是否計算黑名單"
      elif update_type == "1":
          column_to_update = "CARDO點數"
  
      command_text = ""
      # update table with different method
      if update_method == "0":
          command_text = "UPDATE cardo_main.點數記錄表_目前 SET " + column_to_update + " = 0 WHERE 姓名 = " + name_to_update + ";"
      elif update_method == "1":
          command_text = "UPDATE cardo_main.點數記錄表_目前 SET " + column_to_update + " = " + update_point + \
                         " WHERE `姓名` = \'" + name_to_update + "\';"
          # command_text = "UPDATE cardo_main.點數記錄表_目前 SET " + column_to_update + " = 0 WHERE 姓名 = " + name_to_update + ";"
      elif update_method == "2":
          select_command = "SELECT " + column_to_update + " FROM cardo_main.點數記錄表_目前 WHERE 姓名 = \'" + name_to_update + "\';"
          data_return = pd.read_sql(select_command, conn)
          update_point = str(int(data_return.iloc[0, 0]) - int(update_point))
          command_text = "UPDATE cardo_main.點數記錄表_目前 SET " + column_to_update + " = " + update_point + " WHERE 姓名 = \'" + name_to_update + "\';"
  
      # execute command
      conn_cursor.execute("SET SQL_SAFE_UPDATES = 0;")
      conn.commit()
      conn_cursor.execute(command_text)
      conn.commit()
  
apis: pandas.read_sql