<commit_before>import atpy
import os
import getpass

# The default for the databases is to connect with the current username and
# password "<PASSWORD>".

username = getpass.getuser()
password = "<PASSWORD>"


def test_write(t, verbose=False, vector_columns=False, \
    table_set=False):

    # Read in AJ VO Table

    print "Writing VO Table ... ",
    try:
        t.write('temp.xml', verbose=False)
        print "passed"
        os.remove('temp.xml')
    except:
        print "failed"

    # Convert to FITS Table

    print "Writing FITS Table ... ",
    try:
        t.write('temp.fits', overwrite=True, verbose=False)
        print "passed"
        os.remove('temp.fits')
    except:
        print "failed"

    # Convert to IPAC Table

    if not table_set:
        print "Writing IPAC Table ... ",
        try:
            t.write('temp.tbl', verbose=False)
            os.remove('temp.tbl')
            if vector_columns:
                print "failed"
            else:
                print "passed"
        except atpy.VectorException:
            if vector_columns:
                print "passed"
            else:
                print "failed"
        except:
            print "failed"

    # Convert to SQLite databases

    print "Converting to PostGreSQL database ... ",
    try:
        t.write('postgres', database='python', user=username, overwrite=True, \
            verbose=False)
        if vector_columns:
            print "failed"
        else:
            print "passed"
    except atpy.VectorException:
        if vector_columns:
            print "passed"
        else:
            print "failed"
    except:
        print "failed"

    print "Converting to SQLite database ... ",
    try:
        t.write('sqlite', 'temp1.db', overwrite=True, verbose=False)
        if vector_columns:
            print "failed"
        else:
            print "passed"
    except atpy.VectorException:
        if vector_columns:
            print "passed"
        else:
            print "failed"
    except:
        print "failed"

    print "Converting to MySQL database ... ",
    try:
        t.write('mysql', db='python', user=username, passwd=password, \
            overwrite=True, verbose=False)
        if vector_columns:
            print "failed"
        else:
            print "passed"
    except atpy.VectorException:
        if vector_columns:
            print "passed"
        else:
            print "failed"
    except:
        print "failed"

# Read in IRSA IPAC Table

print "Reading IPAC Table ... ",
try:
    t = atpy.Table('examples/2mass.tbl', name='irsa', verbose=False)<commit_msg>- minor bug fix<commit_after>import atpy
import os
import getpass

# The default for the databases is to connect with the current username and
# password "<PASSWORD>".

username = getpass.getuser()
password = "<PASSWORD>"


def test_write(t, verbose=False, vector_columns=False, \
    table_set=False):

    # Read in AJ VO Table

    print "Writing VO Table ... ",
    try:
        t.write('temp.xml', verbose=False)
        print "passed"
        os.remove('temp.xml')
    except:
        print "failed"

    # Convert to FITS Table

    print "Writing FITS Table ... ",
    try:
        t.write('temp.fits', overwrite=True, verbose=False)
        print "passed"
        os.remove('temp.fits')
    except:
        print "failed"

    # Convert to IPAC Table

    if not table_set:
        print "Writing IPAC Table ... ",
        try:
            t.write('temp.tbl', verbose=False)
            os.remove('temp.tbl')
            if vector_columns:
                print "failed"
            else:
                print "passed"
        except atpy.VectorException:
            if vector_columns:
                print "passed"
            else:
                print "failed"
        except:
            print "failed"

    # Convert to SQLite databases

    print "Converting to PostGreSQL database ... ",
    try:
        t.write('postgres', database='python', user=username, overwrite=True, \
            verbose=False)
        if vector_columns:
            print "failed"
        else:
            print "passed"
    except atpy.VectorException:
        if vector_columns:
            print "passed"
        else:
            print "failed"
    except:
        print "failed"

    print "Converting to SQLite database ... ",
    try:
        t.write('sqlite', 'temp.db', overwrite=True, verbose=False)
        if vector_columns:
            print "failed"
        else:
            print "passed"
    except atpy.VectorException:
        if vector_columns:
            print "passed"
        else:
            print "failed"
    except:
        print "failed"

    if os.path.exists('temp.db'):
        os.remove('temp.db')

    print "Converting to MySQL database ... ",
    try:
        t.write('mysql', db='python', user=username, passwd=password, \
            overwrite=True, verbose=False)
        if vector_columns:
            print "failed"
        else:
            print "passed"
    except atpy.VectorException:
        if vector_columns:
            print "passed"
        else:
            print "failed"
    except:
        print "failed"

# Read in IRSA IPAC Table

print "Reading IPAC Table ... ",
try:
    t = atpy.Table('examples/2mass.tbl', name='irsa', verbose=False)
{'fraction_non_alphanumeric': 0.10313732857411234, 'fraction_numerical': 0.0005635919594213789, 'mean_word_length': 1.75, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4572967', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1455, 'n_words': 421}