The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Roh
By Guest on 9th January 2019 08:29:05 PM | Syntax: TEXT | Views: 9



New paste | Download | Show/Hide line no. | Copy text to clipboard
  1. from flask import Flask
  2. from flask_sqlalchemy import SQLAlchemy
  3. app = Flask(__name__)
  4.  
  5.  
  6. app.config['SQLALCHEMY_DATABASE_URI'] = 'mssql+pyodbc://rohini@p1-data-analysis3:pAeNWtdtJRjX7DIo8sqR@p1-data-analysis3.database.windows.net:1433/p1-data-analysis2'
  7.  
  8. db = SQLAlchemy(app)
  9.  
  10.  
  11.  
  12.  
  13. # # from flask import Flask
  14. # from flask import Flask,request,jsonify
  15. # from numpy import asarray
  16. # from flaskext.mysql import MySQL
  17.  
  18. # mysql = MySQL()
  19. # app = Flask(__name__)
  20. # app.config['MYSQL_DATABASE_USER'] = 'rohini@p1-data-analysis3'
  21. # app.config['MYSQL_DATABASE_PASSWORD'] = 'pAeNWtdtJRjX7DIo8sqR'
  22. # app.config['MYSQL_DATABASE_DB'] = 'p1-data-analysis2'
  23. # app.config['MYSQL_DATABASE_HOST'] = 'p1-data-analysis3.database.windows.net'
  24. # mysql.init_app(app)
  25.  
  26.  
  27. # def dictify(a):
  28. #     return [dict(zip(("id","name"),vv)) for vv in a]
  29.  
  30. # @app.route("/")
  31. # def hello():
  32. #     return "Welcome to Python Flask App!"
  33.  
  34. # # http://127.0.0.1:5000/Authenticate?UserName=1&Password=test
  35. # @app.route("/Authenticate")
  36. # def Authenticate():
  37. #     username = request.args.get('UserName')
  38. #     password = request.args.get('Password')
  39. #     cursor = mysql.connect().cursor()
  40. #     cursor.execute("SELECT * from first where id='" + username + "' and description='" + password + "'")
  41. #     data = cursor.fetchone()
  42. #     if data is None:
  43. #      return "Username or Password is wrong"
  44. #     else:
  45. #      return "Logged in successfully"
  46.  
  47. # @app.route("/AllUsers")
  48. # def allUsers():
  49. #     dbconn = mysql.connect()
  50. #     cursor = dbconn.cursor()
  51. #     cursor.execute("SELECT * from first")
  52. #     print(cursor)
  53. #     data = cursor.fetchall()
  54. #     if data is None:
  55. #         return "Bad Request"
  56. #     else:
  57. #         return(jsonify(dictify(asarray(data))))
  58.    
  59. #     cursor.close()
  60. #     dbconn.close()
  61.  
  62.  
  63. # if __name__ == "__main__":
  64. #     app.run()



  • Recent Pastes