Skip to content

Instantly share code, notes, and snippets.

@toritori0318
Created April 4, 2013 06:57
Show Gist options
  • Save toritori0318/5308401 to your computer and use it in GitHub Desktop.
Save toritori0318/5308401 to your computer and use it in GitHub Desktop.
SQLログ出ない(´・ω・`)
# encoding:utf-8
# via http://docs.sqlalchemy.org/en/rel_0_8/core/engines.html#dbengine-logging
import pdb
import logging
logging.basicConfig()
logging.getLogger('sqlalchemy.engine').setLevel(logging.DEBUG)
logging.getLogger('sqlalchemy.dialects').setLevel(logging.DEBUG)
logging.getLogger('sqlalchemy.pool').setLevel(logging.DEBUG)
logging.getLogger('sqlalchemy.orm').setLevel(logging.DEBUG)
from sqlalchemy import create_engine
from sqlalchemy.sql import text
from config import DSN
# setup sqlalchemy
engine = create_engine(DSN, encoding='utf-8', echo=True)
conn = engine.connect()
s = text("select * from user")
result = conn.execute(s).fetchall()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment