Skip to content

Instantly share code, notes, and snippets.

View albarrentine's full-sized avatar
🐙
👾

Al B albarrentine

🐙
👾
View GitHub Profile
@albarrentine
albarrentine / gist:984866
Created May 21, 2011 20:20
SQLAlchemy & pseudo-hash indexing in MySQL
import binascii
def crc32(val):
"""Have to do this with binascii's crc32 which is signed (MySQL's is unsigned)"""
return binascii.crc32(val) & 0xffffffff
def crc32_of(other_field):
"""Context sensitive default for SQLAlchemy inserts
Usage (in model definition):