From 4833970082cac327a8869977a6dacec8082d4c59 Mon Sep 17 00:00:00 2001 From: Tiramisu 1993 Date: Tue, 9 Aug 2016 13:59:52 +0800 Subject: [PATCH] make seta works on heroku --- Procfile | 1 + database/config.py | 10 ++++++++-- requirements.txt | 2 +- setup.py | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 Procfile diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..20657a9 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: python src/server.py diff --git a/database/config.py b/database/config.py index 09e43e2..c6f3180 100644 --- a/database/config.py +++ b/database/config.py @@ -1,9 +1,15 @@ +import os +import urlparse from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker -from sqlalchemy.ext.declarative import declarative_base -engine = create_engine('mysql+mysqldb://root:root@localhost/ouija2', echo=True) +DBURL = urlparse.urlparse(os.environ["DATABASE_URL"]) + +databaseUrl = 'postgresql+psycopg2://{username}:{password}@{host}:{port}/{database}' +engine = create_engine(databaseUrl.format(username=DBURL.username, password=DBURL.password, + host=DBURL.hostname, port=DBURL.port, + database=DBURL.path[1:]), echo=True) Session = sessionmaker(engine) session = Session() diff --git a/requirements.txt b/requirements.txt index 3f3f7ae..04bb444 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ Flask==0.10.1 MarkupSafe==0.23 -MySQL-python==1.2.5 +psycopg2==2.6.2 Flask-SQLAlchemy==2.1 argparse==1.2.1 requests==2.9.1 diff --git a/setup.py b/setup.py index 3eb31a9..5702ffd 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ required = [ "Flask", "MarkupSafe", - "MySQL-python", + "psycopg2", "argparse", "requests", "redo"