Skip to content

Instantly share code, notes, and snippets.

@oucb
oucb / async-mysql.py
Created August 4, 2018 03:39 — forked from syfun/async-mysql.py
python async mysql redis http
import asyncio
import aiomysql
from aiomysql.cursors import DictCursor
class MysqlWrapper:
def __init__(self, host, port, user, password, db):
self.host = host
self.port = port
@oucb
oucb / gist:4a6ead1574c72568c2f4d8b60e9384b3
Created June 15, 2018 10:09 — forked from hest/gist:8798884
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@oucb
oucb / hs.md
Created June 21, 2012 06:27 — forked from jackywyz/hs.md
Haskell总结

###haskell 基本类型,bool(True/False),list[],tuple(),int,Integer,Double,char'' ,string"",function(\x->x+1)

  1. wiki