Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask
- import pyodbc
- app = Flask(__name__)
- def connect():
- cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=localhost;DATABASE=testdb;UID=me;PWD=pass')
- return cnxn.cursor()
- cursor = connect()
- @app.route('/ali_request_user')
- def get_user_id():
- cursor.execute("select user_id, user_name from users")
- rows = cursor.fetchall()
- return rows
- @app.route('/ali_request_image')
- def getEloScore(image):
- cursor.execute("""
- SELECT [EloScore]
- FROM [dbo].[Elo]
- WHERE [ImagePath] = ?
- """, image)
- return cursor.fetchone()
- def getVotes(username):
- cursor.execute("""
- SELECT [ImagePath1]
- ,[ImagePath2]
- FROM [dbo].[Vote]
- WHERE [Username] = ?
- """, username)
- return cursor.fetchall()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement