Last active
October 29, 2018 15:06
-
-
Save Kotauror/e121bbf170c61d34c70fffbd7f135b41 to your computer and use it in GitHub Desktop.
psql1.py
This file contains hidden or 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
from flask import Flask | |
import time | |
import os | |
from models import db | |
from flask_sqlalchemy import SQLAlchemy | |
from models import Contact | |
app = Flask(__name__) | |
POSTGRES = { | |
'user': 'myUserName', | |
'pw': 'myPassword', | |
'db': 'myDBName', | |
'host': 'endPoint', | |
'port': '5432', | |
} | |
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://%(user)s:\ | |
%(pw)s@%(host)s:%(port)s/%(db)s' % POSTGRES | |
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False | |
db.init_app(app) | |
@app.route('/') | |
def hello_world(): | |
contacts = Contact.query.all() | |
return "We have " + str(len(contacts)) + " in the db and the contact names are: " + contacts[0].name + " and " + contacts[1].name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment