Guest User

Untitled

a guest
Sep 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. import pymysql
  2.  
  3. def get_item(_list, _key):
  4. return [i[2:4] for i in _list if _key in i]
  5.  
  6.  
  7. conn = pymysql.connect(host='localhost', user='root', password='',db='',charset='utf8')
  8.  
  9. curs = conn.cursor()
  10. sql = "select * from tb_cat"
  11. curs.execute(sql)
  12.  
  13. rows = list(curs.fetchall())
  14. print(type(rows))
  15.  
  16. conn.close()
  17.  
  18. print(get_item(rows, "id_coffee"))
Add Comment
Please, Sign In to add comment