Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added Unit-01/07-sql-alchemy-2/app.py
Empty file.
28 changes: 28 additions & 0 deletions Unit-01/07-sql-alchemy-2/templates/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from flask import Flask,request,redirect, render_template, url_for
from flask_sqlalchemy import SQLAlchemy
from flask_modus import Modus

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = "postgres://localhost/users-messages"

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
modus = Modus(app)
db = SQLAlchemy(app)

class User(db.Model):

__tablename__ = 'users'

id = db.Column(db.Integer,primary_key = True)
first_name = db.Column(db.Text)
last_name = db.Column(db.Text)

def __init__(self,first_name,last_name):
self.first_name = first_name
self.last_name = last_name




if __name__ == '__main__':
app.run(debug=True,port=3000)
12 changes: 12 additions & 0 deletions Unit-01/07-sql-alchemy-2/templates/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from app import app,db

from flask_script import Manager
from flask_migrate import Migrate,MigrateCommand

migrate = Migrate(app,db)
manager = Manager(app)

manager.add_command('db',MigrateCommand)

if __name__ == '__main':
manager.run()
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.