title: How to Show multiple record from table mysql to telegram bot with python , and only certain phone number can access to my bot telegram
body: <p>im still beginner with python script. I want to ask like the title name,
  i got idea innovation for monitoring KPI on my office, and almost done. but there are problem can't finished by myself. </p>
  
  <p>How to Show multiple record from table mysql to telegram bot with python , and only certain phone number can access to my bot telegram ?</p>
  
  <p>This my script :</p>
  
  <p><strong>'How to show multiple record from table mysql to telegram bot'</strong></p>
  
  <pre><code>def query(requ):
  cursor = db.cursor()
  sql = "SELECT * FROM monitor WHERE Tanggal LIKE '%" + str(requ.encode('utf-8')) + "%'"
  
  try:
      cursor.execute(sql)
      # memecahkan hasil dari table
      results = cursor.fetchall()
  
      # memberikan hasil jika hasil sesuai sama tabel maka keluar sesuai hasil
      if len(results)&gt;0:
          output = ''
          for row in results:
              Tanggal = row[0]
              DOWNTIME_PLN = row[1]
              RUN_GENSET = row[2]
              SHREDDER_MILL_DOWNTIME = row[3]
              SHREDDER_CRUMB_DOWNTIME = row[4]
              SHREDDER_CRUMB_AMPERE = row[5]
              has_trans = row[6]
              # Now print fetched result
              output = "Tanggal = %s, \nDOWNTIME_PLN = %d, \nRUN_GENSET = %s, \nSHREDDER_MILL_DOWNTIME = %s, \nSHREDDER_CRUMB_DOWNTIME=%s, \nSHREDDER_CRUMB_AMPERE=%s, \nhas_trans = %s" % \
              (Tanggal,DOWNTIME_PLN,RUN_GENSET,SHREDDER_MILL_DOWNTIME,SHREDDER_CRUMB_DOWNTIME,SHREDDER_CRUMB_AMPERE,has_trans)
              print (Tanggal,DOWNTIME_PLN,RUN_GENSET,SHREDDER_MILL_DOWNTIME,SHREDDER_CRUMB_DOWNTIME,SHREDDER_CRUMB_AMPERE,has_trans)
      else:
          output = 'No word in my dic'
  except:
      output = 'error'
  return output
  </code></pre>
  
  <p>'How to only certain phone number can access to my bot telegram ?'</p>
  
  <pre><code>def handle(msg):
  #Deklarasi untuk profile Telegram
  chat_id = msg['chat']['id']
  command = msg['text']
  user_id = msg['from']['id']
  username = msg['from']['first_name']
  fullname = msg['from']['last_name']+msg['from']['first_name']
  timestr = time.strftime("%Y-%m-%d_%H")
  
  content_type, chat_type, chat_id = telepot.glance(msg)
  
  if (content_type == 'text'):
      command = msg['text']
      print ('Got command: %s' % command)
      #Dekklarasi command apa saja yang mau dimasukin
      if command == 'halo':
          keyboard = [
              ['Halo', 'erlang'],
              ['cpu', 'ddd'],
              ['ccc'],['Tutup']
          ]
          reply_markup = ReplyKeyboardMarkup.create(keyboard)
          bot.sendMessage(chat_id, "Assalamu'alaikum "+username+", ..?",reply_markup=reply_markup)
      elif command == 'erlang':
          bot.sendPhoto(chat_id=chat_id, photo=open('E:/@@@/@smartfren/capture trial/Compare_KPI_1' + '.jpg','rb'))
          bot.sendPhoto(chat_id=chat_id, photo=open('E:/@@@/@smartfren/capture trial/Compare_KPI_2' + '.jpg','rb'))
      elif command == 'cpu':
          print ('Got command: %s' % timestr + command)
          bot.sendMessage(chat_id=chat_id, :test:)
      elif 'Tutup' in command:
          hide_keyboard = {'hide_keyboard': True}
          bot.sendMessage(chat_id, 'Fungsi KeyBoard ditutup!', reply_markup=hide_keyboard)
      elif 'ccc' in command:
          reps_content = query(command)
          bot.sendMessage(chat_id, reps_content)
      elif 'ddd' in command:
          reps_content = query2(command)
          bot.sendMessage(chat_id, reps_content)
  </code></pre>
  
  <p>Thanks :)</p>