flask-contacts/models.py
Andros Fenollosa 663a94a305 Add postgres
2018-05-01 13:58:24 +02:00

22 lines
792 B
Python

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://bgcmtrdgusuwik:05060b67183fb8ba7ddb937aaec3f6a20617b3bbd547ce89a19eceb760f6fa4b@ec2-54-217-217-142.eu-west-1.compute.amazonaws.com:5432/d2po2asdglml7g'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
class Contact(db.Model):
__tablename__ = 'contacts'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), nullable=False)
surname = db.Column(db.String(100), nullable=True)
email = db.Column(db.String(200), nullable=True, unique=True)
phone = db.Column(db.String(20), nullable=True, unique=False)
def __repr__(self):
return '<Contacts %r>' % self.name