def sql(*args, **kwargs):
    """
    Replicates wrds.sql with auto-login if necessary. Pass query string and index. Documentation
    from wrds.sql below:
    
    Run a SQL Query on the WRDS Database.
    data = wrds.sql('select * from CRSP.MSI', 'DATE')

    The second argument gives the column name of the index, if you'd like
    your DataFrame to be indexed.
    """
#     if not wrds_obj:
#         import wrds
#         wrds_obj = wrds

    wrds_obj = kwargs.pop('wrds_obj')
    
    return wrds_obj.sql(*args, **kwargs)