Skip to content

Instantly share code, notes, and snippets.

@lucidguppy
Created March 1, 2013 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucidguppy/5062112 to your computer and use it in GitHub Desktop.
Save lucidguppy/5062112 to your computer and use it in GitHub Desktop.
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...
@app.route("/add_reading")
def add_data():
data = {'temperature': randrange(-40,140)}
stmt = t.temperature_table.insert()
res = stmt.execute(data)
return render_template('added_temp.html', results=res)
...blah blah blah...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment