Ingen beskrivning

api.py 515B

1234567891011121314151617181920
  1. from flask import Flask, request, jsonify
  2. from flask_sqlalchemy import sqlalchemy
  3. from flask_marshmallow import Marshmallow
  4. from sqlalchemy import create_engine
  5. import pymysql
  6. import secrets
  7. #initialize api
  8. conn = 'mysql://{0}:{1}@{2}:{3}/{4}'.format(secrets.dbuser, secrets.dbpassword, secrets.dbhost, secrets.dbport ,secrets.dbname)
  9. engine = create_engine(conn)
  10. connection = engine.connect()
  11. query = "Select * tablename"
  12. results = connection.execute(query)
  13. if __name__ == '__main__':
  14. app.run(debug=True)