blob: 7ac225c62994be0dfa5555ddb5bc6896c9773a64 [file] [log] [blame]
stgleb75c70412015-02-17 02:52:00 +02001from flask import Flask, render_template, request, url_for, request, redirect
2from flask.ext.sqlalchemy import SQLAlchemy
3import sqlite3
4import os
5
6app = Flask(__name__)
7sqlite3.connect(os.path.abspath("test.db"))
8app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///test.db"
9db = SQLAlchemy(app)
10
11
12class User(db.Model):
13 id = db.Column(db.Integer, primary_key=True)
14 username = db.Column(db.String(80), unique=True)
15 email = db.Column(db.String(120), unique=True)
16
17 def __init__(self, username, email):
18 self.username = username
19 self.email = email
20 def __repr__(self):
21 return "<User %r>" % self.username
22
23
24db.create_all()
25x = User("tes2t", "test2@gmail.com")
26db.session.add(x)
27db.session.commit()
28
29