forked from tarunkay7/PsyCred
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
13 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
from flask import Flask, jsonify | ||
import pyodbc | ||
import sqlite3 | ||
|
||
app = Flask(__name__) | ||
|
||
# Configuration | ||
CONNECTION_STRING = 'Driver={ODBC Driver 18 for SQL Server};Server=tcp:dbserverpsy.database.windows.net,1433;Database=psycredDB;Uid={your_user_name};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;Authentication=ActiveDirectoryIntegrated' | ||
|
||
DATABASE = 'psycreditdb.db' | ||
|
||
def get_db_connection(): | ||
return pyodbc.connect(CONNECTION_STRING) | ||
|
||
return sqlite3.connect(DATABASE) | ||
|
||
@app.route('/') | ||
def index(): | ||
def test_connection(): | ||
try: | ||
conn = get_db_connection() | ||
if conn: | ||
return jsonify("Connected") | ||
conn.close() | ||
return jsonify({'status': 'connected'}) | ||
except Exception as e: | ||
return str(e) | ||
|
||
return jsonify({'status': 'error', 'message': str(e)}) | ||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) |
Empty file.