Skip to content

Instantly share code, notes, and snippets.

@batok
Created October 21, 2011 17:19
Show Gist options
  • Save batok/1304382 to your computer and use it in GitHub Desktop.
Save batok/1304382 to your computer and use it in GitHub Desktop.
When using clear_mappers is executed , celery mappings also got cleared
@task
def columns( table = "usuarios"):
try:
t = Table( table , metadata, autoload = True, autoload_with = engine)
try:
clear_mappers() # this clean all previous mappers if any
mapper( Dummy, t )
except:
traceback.print_exc()
return "error"
result = ["Table {} ( {} recs)".format(table, session.query( Dummy ).count())]
for x in metadata.tables[table].columns:
result.append("{:<40s} {}".format( x.name, x.type))
return "\n".join(result)
except:
traceback.print_exc()
return "error"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment