alchemy shit

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
db = create_engine('sqlite:////'+os.path.join(config.SECRET_PATH, 'blog.db'))
metadata = MetaData(db)
blog = Table('blog', metadata,
Column('id', Integer, primary_key=True),
Column('author', String),
Column('subject', String),
Column('entry', String),
Column('slug', String, unique=True),
Column('tags', String),
Column('date', DateTime, default=func.current_timestamp()),
)
def getPagesBytag(tag):
print select([blog], order_by=[desc(blog.c.date)], whereclause=(blog.c.tags.like("123")))#.execute()
return select([blog], order_by=[desc(blog.c.date)], whereclause=(blog.c.tags.like(tag))).execute().fetchall()
___________
SELECT blog.id, blog.author, blog.subject, blog.entry, blog.slug, blog.tags, blog.date FROM blog WHERE blog.tags LIKE ? ORDER BY blog.date DESC []