Permalink
Please sign in to comment.
Showing
with
63 additions
and 0 deletions.
- +1 −0 Procfile
- +44 −0 README.md
- +16 −0 connection.py
- +2 −0 requirements.txt
| @@ -0,0 +1,44 @@ | ||
| +## Install PostSQL for python library | ||
| + | ||
| +The query execution is based on PostgreSQL's python library -- , it needs to be installed on the server first. | ||
| +1. On terminal, open bash | ||
| +``` | ||
| + $sudo bash | ||
| +``` | ||
| +2. Adding system variables | ||
| +``` | ||
| + $export CFLAGS=-Qunused-arguments | ||
| + $export CPPFLAGS=-Qunused-arguments | ||
| +``` | ||
| +3. Install using pip: | ||
| +``` | ||
| + $pip install PyGreSQL | ||
| +``` | ||
| + | ||
| +## Set up: | ||
| +1. Clone this repo | ||
| +2. Config your database name, host, port, user name, and password in ```connection.py``` | ||
| +```python | ||
| +db = DB(dbname='',host='',port= ,user='',passwd='') | ||
| +``` | ||
| +3. Deploy this to server | ||
| +4. Add this integration to your Slack | ||
| +5. All set! | ||
| + | ||
| +## Slack command: | ||
| +- create table: | ||
| +``` | ||
| + /sql create table users(id primary key, name varchar) | ||
| +``` | ||
| +- Insert data: | ||
| +``` | ||
| + /sql insert into users values(1, 'Seth Wang') | ||
| +``` | ||
| +- selection: | ||
| +``` | ||
| + /sql select users.name from users where id=1 | ||
| +``` | ||
| +- deletion | ||
| +``` | ||
| + /sql delete from users where id=2 | ||
| +``` |
| @@ -0,0 +1,16 @@ | ||
| +from pg import DB | ||
| +import os | ||
| +from flask import Flask, request, Response, redirect | ||
| + | ||
| +db = DB(dbname='d4pvr81kbkvo46',host='ec2-23-21-157-223.compute-1.amazonaws.com', port=5432, user='oqjvqwymcazkhw',passwd='cQb5tvoVzhfr8yZNYA6B0dSdJq') | ||
| +app = Flask(__name__) | ||
| + | ||
| +@app.route("/", methods=['post']) | ||
| +def hello(): | ||
| + q = request.values.get('text') | ||
| + result = str(db.query(q)) | ||
| + return result | ||
| + | ||
| +if __name__ == "__main__": | ||
| + port = int(os.environ.get('PORT', 5000)) | ||
| + app.run(host='0.0.0.0', port=port) |
| @@ -0,0 +1,2 @@ | ||
| +PyGreSQL==5.0 | ||
| +flask==0.10.1 |
0 comments on commit
3a8c982