Skip to content

Instantly share code, notes, and snippets.

from flask import render_template
from random import randrange
#create the app object
app = Flask(__name__)
#get the database
from tables import engine, temperature_table
@app.before_request
def before_request():
@lucidguppy
lucidguppy / app.py
Created March 1, 2013 02:46
Access a sqlalchemy database through importing it.
from flask import Flask
from flask import render_template
from random import randrange
#create the app object
app = Flask(__name__)
#get the database
import tables as t
..blah blah blah...
@lucidguppy
lucidguppy / tables.py
Created March 1, 2013 02:38
Create an sql table
from sqlalchemy import *
from datetime import datetime
metadata = MetaData('postgres://blah blah blah')
temperature_table = Table(
'tf_temperatures', metadata,
Column('id', Integer, primary_key=True),
Column('temperature', Float, nullable=False),
Column('datetime',DateTime, default=datetime.now))