Skip to content

Commit 9016694

Browse files
author
Didarul Amin
committed
Update
1 parent e14e0d5 commit 9016694

File tree

8 files changed

+25
-12
lines changed

8 files changed

+25
-12
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ RUN \
3838
#apt-get autoremove -y && apt-get autoclean -y
3939

4040
# install pyodbc (and, optionally, sqlalchemy)
41-
RUN pip install --trusted-host pypi.python.org pyodbc==4.0.26 sqlalchemy==1.3.5
41+
RUN pip install --trusted-host pypi.python.org pyodbc==4.0.26 sqlalchemy==1.3.5 pandasql seaborn
42+
4243

4344
ENV FLASK_APP=server.py
4445

sqlpad/connectionaccesses.db

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{"connectionId":"__EVERY_CONNECTION__","connectionName":"Every Connection","userId":"__EVERYONE__","userEmail":"Everyone","duration":0,"expiryDate":{"$$date":4074946793949},"_id":"n2gIN125q2VCYuKw"}
1+
{"connectionId":"__EVERY_CONNECTION__","connectionName":"Every Connection","userId":"__EVERYONE__","userEmail":"Everyone","duration":0,"expiryDate":{"$$date":4074965569026},"_id":"n2gIN125q2VCYuKw"}
22
{"$$indexCreated":{"fieldName":"connectionId","unique":false,"sparse":false}}
33
{"$$indexCreated":{"fieldName":"userId","unique":false,"sparse":false}}
4-
{"connectionId":"__EVERY_CONNECTION__","connectionName":"Every Connection","userId":"__EVERYONE__","userEmail":"Everyone","duration":0,"expiryDate":{"$$date":4074965569026},"_id":"n2gIN125q2VCYuKw"}

sqlpad/sessions/7IOyOho9hxKRravjJ4qcdnhuKEZkGBiM.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

sqlpad/sessions/e63GR5B6d5PVxlyp2-AyuCugU7BMQ9OH.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

sqlpad/sessions/muZ54P0uLXT2pCMGho6hxNO0wPKZi29k.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

sqlpad/users.db

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
{"email":"admin@admin.com","role":"admin","passhash":"$2a$10$U5Ehdi/6BZOyx5LSChZryewQGAro.IG/b/KUyBOTw0OV8BIReoOIS","_id":"u5lvkzWt9RyNEpwu"}
2-
{"$$indexCreated":{"fieldName":"email","unique":true,"sparse":false}}
31
{"email":"admin@admin.com","role":"admin","passhash":"$2a$10$H3ycTXufqoa5Yrs.qLCmBOqgq31CpD77417SH463oQXRRX8UBfnSi","_id":"u5lvkzWt9RyNEpwu"}
2+
{"$$indexCreated":{"fieldName":"email","unique":true,"sparse":false}}

src/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
Flask==1.1.1
22
gunicorn==19.9.0
3+
pandas==0.23.4
4+
numpy==1.14.6
5+
Keras==2.1.4
6+
tensorflow==1.13.1
7+
flask_cors==3.0.8
8+
simplejson==3.16.0

src/server.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import pyodbc
2-
from flask import Flask, request, make_response
2+
import pandasql as ps
3+
from flask import Flask, render_template, jsonify,request,make_response
4+
import pandas as pd
5+
36
app = Flask(__name__)
47

58
# Get Driver from cat /etc/odbcinst.ini
6-
79
drivers = [item for item in pyodbc.drivers()]
810
driver = drivers[-1]
911
print("driver:{}".format(driver))
@@ -13,15 +15,24 @@
1315
pwd = 'SuperP4ssw0rd!'
1416
conn = f'DRIVER={driver};SERVER={server};DATABASE={database};UID={uid};PWD={pwd}'
1517

18+
# Copy to Clipboard for paste in Excel sheet
19+
def copia (argumento):
20+
df=pd.DataFrame(argumento)
21+
df.to_clipboard(index=False,header=True)
22+
23+
1624
@app.route('/')
1725
def index():
1826
cnxn = pyodbc.connect(conn)
1927
cursor = cnxn.cursor()
2028
print ('Using the following SQL Server version:')
2129
#tsql = "SELECT @@version;"
2230
tsql = "SELECT * FROM dbo.Customers"
31+
df = pd.read_sql(tsql, cnxn)
32+
2333
with cursor.execute(tsql):
2434
row = cursor.fetchone()
2535
response = make_response(str(row), 200)
26-
response.headers["Content-Type"] = "text/plain"
27-
return response
36+
response.headers["Content-Type"] = "application/json"
37+
return jsonify({"Name": str(df.head) + ' ' + str(row[1])})
38+

0 commit comments

Comments
 (0)