Skip to content

Instantly share code, notes, and snippets.

@fanzeyi
Created January 10, 2015 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fanzeyi/ec12b96591b18d197454 to your computer and use it in GitHub Desktop.
Save fanzeyi/ec12b96591b18d197454 to your computer and use it in GitHub Desktop.
integrate GB2260 with SQLAlchemy
# -*- coding: utf-8 -*-
import gb2260
import sqlalchemy.types as types
class ChineseDistrict(types.TypeDecorator):
impl = types.Integer
def process_bind_param(self, value, dialect):
return int(value.code)
def process_result_value(self, value, dialect):
return gb2260.get(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment