This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import with_statement | |
from alembic import context | |
from sqlalchemy import engine_from_config, pool, MetaData, Table, ForeignKeyConstraint | |
from logging.config import fileConfig | |
# this is the Alembic Config object, which provides | |
# access to the values within the .ini file in use. | |
config = context.config | |
# Interpret the config file for Python logging. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask.ext.sqlalchemy import SQLAlchemy | |
db = SQLAlchemy() | |
class Tenant(db.Model): | |
__tablename__ = 'tenant' | |
name = db.Column(db.String, nullable=False, unique=True, primary_key=True) | |
__table_args__ = {"schema_name":"public"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ createdb testext | |
$ psql testext | |
psql (9.3.5) | |
Type "help" for help. | |
testext=# create schema things; | |
CREATE SCHEMA | |
testext=# set search_path to things,public; | |
SET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name":{ | |
"middle":"John" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, Response | |
from flask.ext.sqlalchemy import SQLAlchemy | |
from werkzeug.local import LocalProxy | |
app = Flask(__name__) | |
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' | |
app.config["SQLALCHEMY_ECHO"] = True | |
db = SQLAlchemy(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import * | |
from flask.ext.sqlalchemy import SQLAlchemy | |
from sqlalchemy.orm import Query | |
class MyQuery(Query): pass | |
db = SQLAlchemy(session_options={'query_cls': MyQuery}) | |
class MyModel(db.Model): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Routes location="history"> | |
<Route handler={AdminLayout} flux={flux}> | |
<Route name="home" path="/" handler={FrontPage}/> | |
</Route> | |
<Route handler={AuthenticationLayout}> | |
<Route name="sign-in" path="/sign-in" handler={LoginForm} /> | |
</Route> | |
</Routes> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, ForeignKey, Integer, String, ForeignKeyConstraint | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import sessionmaker, relationship | |
Base = declarative_base() | |
class Tenant(Base): | |
__tablename__ = 'tenant' | |
id = Column(Integer, primary_key=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip install pillow | |
Downloading/unpacking pillow | |
Downloading Pillow-2.5.3-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.whl (3.0MB): 3.0MB downloaded | |
Installing collected packages: pillow | |
Successfully installed pillow | |
Cleaning up... | |
$ python | |
Python 2.7.5 (default, Mar 9 2014, 22:15:05) | |
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Foo do | |
defmacro __using__(_) do | |
quote do | |
def foo() do | |
IO.puts "Foo" | |
end | |
defoverridable [foo: 0] | |
end | |
end | |
end |