from flask import Flask |
from flask_sqlalchemy import SQLAlchemy |
app = Flask(__name__) |
app.config[ "SQLALCHEMY_DATABASE_URI" ] = "sqlite:///example.db" |
db = SQLAlchemy(app) |
class User(db.Model): |
id = db.Column(db.Integer, primary_key = True ) |
name = db.Column(db.String( 80 ), nullable = False ) |
@app .route( "/" ) |
def home(): |
user = User(name = "John" ) |
db.session.add(user) |
db.session.commit() |
return "Hello, " + user.name |
if __name__ = = "__main__" : |
app.run() |