Skip to content

Instantly share code, notes, and snippets.

@mjallday
Created February 9, 2012 18:01
Show Gist options
  • Save mjallday/1781622 to your computer and use it in GitHub Desktop.
Save mjallday/1781622 to your computer and use it in GitHub Desktop.
unique eid across marketplace
@event.listens_for(Debit, 'before_insert')
def increment_balance(mapper, connection, debit):
eid = generate_eid('D')
result = 1
while result:
result = Debit.query.filter(
Debit.marketplace == debit.marketplace,
Debit.eid == eid
).count()
debit.eid = eid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment