Skip to content
Myr

Merge branch 'master' into module-support

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parents ce53d10, f345af8 · Browse files · 3 files+6 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+6 added−7 removed

  • tests:+3 added−3 removed
  • other:+3 added−4 removed

3 files+6 added−7 removed

modified:docs/patterns/sqlalchemy.rst+3 added-3 removed
23 unmodified lines
24 from sqlalchemy import create_engine25 from sqlalchemy.orm import scoped_session, sessionmaker26 from sqlalchemy.ext.declarative import declarative_base2728 engine = create_engine('sqlite:////tmp/test.db')28 engine = create_engine('sqlite:////tmp/test.db', convert_unicode=True)29 db_session = scoped_session(sessionmaker(autocommit=False,30 autoflush=False,31 bind=engine)) 32 Base = declarative_base()
70 unmodified lines
103104 from sqlalchemy import create_engine, MetaData105 from sqlalchemy.orm import scoped_session, sessionmaker106107 engine = create_engine('sqlite:////tmp/test.db')107 engine = create_engine('sqlite:////tmp/test.db', convert_unicode=True)108 metadata = MetaData()109 db_session = scoped_session(sessionmaker(autocommit=False,110 autoflush=False,111 bind=engine))
43 unmodified lines
155you basically only need the engine::156157 from sqlalchemy import create_engine, MetaData158159 engine = create_engine('sqlite:////tmp/test.db')159 engine = create_engine('sqlite:////tmp/test.db', convert_unicode=True)160 metadata = MetaData(bind=engine)161162Then you can either declare the tables in your code like in the examples163above, or automatically load them::
30 unmodified lines
modified:tests/flask_tests.py+3 added-3 removed
253 unmodified lines
254 assert flask.url_for('static', filename='index.html') \255 == '/static/index.html'256257 def test_none_response(self):258 warnings.filterwarnings('error', 'View function did not return')258 app = flask.Flask(__name__)259 @app.route('/')260 def test():261 return None262 try:263 app.test_client().get('/')265 except Warning:264 except ValueError, e:265 assert str(e) == 'View function did not return a response'266 pass267 else:268 assert "Expected warning"268 assert "Expected ValueError"269270271class JSONTestCase(unittest.TestCase):272
188 unmodified lines
modified:flask.py-1 removed
10 unmodified lines
11"""12from __future__ import with_statement13import os14import sys15import types15from datetime import datetime, timedelta1617from itertools import chain18from jinja2 import Environment, PackageLoader, FileSystemLoader
1021 unmodified lines