Skip to content

Instantly share code, notes, and snippets.

@danioscx
Created March 29, 2020 17:49
Show Gist options
  • Save danioscx/8a31e5a4eb9e28ede99abb8fa0e6988c to your computer and use it in GitHub Desktop.
Save danioscx/8a31e5a4eb9e28ede99abb8fa0e6988c to your computer and use it in GitHub Desktop.
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////path/ke/sqlite.db'
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=False)
def __repr__(self):
return '<User %r>' % self.username
@app.route("/create_db")
def create_db():
db.create_all()
return "database selesai dibuat"
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment