Skip to content

Instantly share code, notes, and snippets.

View robert8138's full-sized avatar

Robert Chang robert8138

  • Airbnb
  • San Francisco
View GitHub Profile
@webapp.route('/dbdisplay')
def display():
return render_template("dbdisplay.html",
events = Events.query.all())
@webapp.route('/dbdisplay/<event_type>')
def display_by_event_type(event_type):
return render_template("dbdisplay.html",
events = (Events.query
.filter_by(event_type = event_type)
from flask.ext.sqlalchemy import SQLAlchemy
from sqlalchemy import Column, Integer, String, Date, Float
db = SQLAlchemy()
class Events(db.Model):
__tablename__ = 'events_full'
id = Column(Integer, primary_key=True)
date = Column(Date)
duration = Column(Float)
@webapp.route('/events/all', methods=['GET'])
def show_all_events():
db = sqlite3.connect("dim_events.sqlite3")
cur = db.execute('select * from dim_events')
rows = cur.fetchall()
return render_template('events.html', rows = rows)
DROP TABLE IF EXISTS dim_events;
CREATE TABLE dim_events (
id INTEGER PRIMARY KEY AUTOINCREMENT,
date DATETIME,
duration REAL,
event_name TEXT
);
@robert8138
robert8138 / hello_world.py
Created March 19, 2016 21:45
hello world
def hello_world():
print "hello world!"