-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (25 loc) · 904 Bytes
/
app.py
File metadata and controls
34 lines (25 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from flask import Flask
from users import users
from flask_sqlalchemy import SQLAlchemy
import pymysql
pymysql.install_as_MySQLdb()
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = "mysql://root:@localhost/company"
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
app.register_blueprint(users)
class People(db.Model):
people_id = db.Column(db.Integer,primary_key=True)
people_name = db.Column(db.Unicode(80))
people_email = db.Column(db.String(255),unique=True)
people_created = db.Column(db.DateTime,nullable=True)
def __init__(self,name,email):
self.people_name = name
self.people_email = email
# db.create_all()
# new_user = People('Umer','umer@mydomain.com')
# db.session.add(new_user)
# db.session.commit()
results = db.engine.execute("SELECT * FROM people")
for person in results:
print(person['people_name'])