Skip to content
Myr

Use unicode in SQLAlchemy pattern.

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 · parent dffb3d0 · Browse files · 1 file+3 added−3 removed
This commit

State

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

Diff stats

1 file+3 added−3 removed

  • other:+3 added−3 removed

1 file+3 added−3 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