Guest User

Untitled

a guest
Mar 18th, 2019
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import flask as fk
  2. import mysql.connector
  3. from mysql.connector import Error
  4. import json
  5.  
  6.  
  7. app = fk.Flask(__name__)
  8.  
  9. @app.route("/")
  10. def temp():
  11. connection = mysql.connector.connect(host='localhost',
  12. database='todolist',
  13. user='root',
  14. password='')
  15. sql_select_Query = "select task, description from task"
  16. cursor = connection.cursor()
  17. cursor.execute(sql_select_Query)
  18. records = cursor.fetchall()
  19. a = cursor.rowcount
  20. print("Total number of rows in python_developers is - ", a)
  21.  
  22. for index, row in enumerate(records):
  23. print("task = ", row[0])
  24. print("description = ", row[1])
  25. #print(type(row))
  26. #b[index] = row
  27. s[index] = json.dumps(row)
  28. cursor.close()
  29. print(type(row))
  30. return s
  31.  
  32.  
  33. if __name__ == "__main__":
  34. app.run()
Add Comment
Please, Sign In to add comment