Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import flask as fk
- import mysql.connector
- from mysql.connector import Error
- import json
- app = fk.Flask(__name__)
- @app.route("/")
- def temp():
- connection = mysql.connector.connect(host='localhost',
- database='todolist',
- user='root',
- password='')
- sql_select_Query = "select task, description from task"
- cursor = connection.cursor()
- cursor.execute(sql_select_Query)
- records = cursor.fetchall()
- a = cursor.rowcount
- print("Total number of rows in python_developers is - ", a)
- for index, row in enumerate(records):
- print("task = ", row[0])
- print("description = ", row[1])
- #print(type(row))
- #b[index] = row
- s[index] = json.dumps(row)
- cursor.close()
- print(type(row))
- return s
- if __name__ == "__main__":
- app.run()
Add Comment
Please, Sign In to add comment