# Path: montage/utils.py
# def load_env_config(env_name=None):
#     if not env_name:
#         env_name = get_env_name()
#     elif env_name == 'devtest':
#         return dict(DEVTEST_CONFIG)
# 
#     config_file_name = 'config.%s.yaml' % env_name
#     config_file_path = os.path.join(PROJ_PATH, config_file_name)
# 
#     try:
#         config = yaml.safe_load(open(config_file_path))
#     except Exception:
#         print '!! failed to load config file: %s' % (config_file_path,)
#         raise
# 
#     config['__env__'] = env_name
#     config['__file__'] = config_file_path
#     return config


import pdb
import sys
import time
import os.path
import argparse
from sqlalchemy import MetaData, create_engine
from montage.utils import load_env_config


# from montage.rdb import Base  # might not drop tables which were removed


def drop_schema(db_url, echo=True):

    # echo="debug" also prints results of selects, etc.
    engine = create_engine(db_url, echo=echo)
    metadata = MetaData()
    metadata.reflect(bind=engine)
    metadata.drop_all(engine)

    return


def main():
    prs = argparse.ArgumentParser('drop montage db')
    add_arg = prs.add_argument
    add_arg('--db_url')
    add_arg('--debug', action="store_true", default=False)
    add_arg('--force', action="store_true", default=False)
    add_arg('--verbose', action="store_true", default=False)

    args = prs.parse_args()

    db_url = args.db_url
    if not db_url:
        # print '==  loading db_url from config'
        try:

# Path: montage/utils.py
# def load_env_config(env_name=None):
#     if not env_name:
#         env_name = get_env_name()
#     elif env_name == 'devtest':
#         return dict(DEVTEST_CONFIG)
# 
#     config_file_name = 'config.%s.yaml' % env_name
#     config_file_path = os.path.join(PROJ_PATH, config_file_name)
# 
#     try:
#         config = yaml.safe_load(open(config_file_path))
#     except Exception:
#         print '!! failed to load config file: %s' % (config_file_path,)
#         raise
# 
#     config['__env__'] = env_name
#     config['__file__'] = config_file_path
#     return config


# Path: tools/drop_schema.py
import pdb
import sys
import time
import os.path
import argparse
from sqlalchemy import MetaData, create_engine
from montage.utils import load_env_config



# from montage.rdb import Base  # might not drop tables which were removed


def drop_schema(db_url, echo=True):

    # echo="debug" also prints results of selects, etc.
    engine = create_engine(db_url, echo=echo)
    metadata = MetaData()
    metadata.reflect(bind=engine)
    metadata.drop_all(engine)

    return


def main():
    prs = argparse.ArgumentParser('drop montage db')
    add_arg = prs.add_argument
    add_arg('--db_url')
    add_arg('--debug', action="store_true", default=False)
    add_arg('--force', action="store_true", default=False)
    add_arg('--verbose', action="store_true", default=False)

    args = prs.parse_args()

    db_url = args.db_url
    if not db_url:
        # print '==  loading db_url from config'
        try:

            config = load_env_config()