Skip to content

Instantly share code, notes, and snippets.

@sairamkrish
Created June 30, 2020 21:00
Show Gist options
  • Save sairamkrish/9c47dc9e0e546b7fb065147b8aa9d4ef to your computer and use it in GitHub Desktop.
Save sairamkrish/9c47dc9e0e546b7fb065147b8aa9d4ef to your computer and use it in GitHub Desktop.
alembic model autogeneration
'''
Automatically add all models to __all__
This is used in alembic while autogenerating database migration script.
'''
from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [ basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment