Example #1
0
def test_postgres_load():
    assert normalize(copy_command('postgresql', tbl, csv)) == normalize("""
    COPY my_table from '%s'
        (FORMAT csv,
         DELIMITER E',',
         NULL '',
         QUOTE '"',
         ESCAPE '\\',
         HEADER True,
         ENCODING 'utf-8');
    """ % escaped_fn)
Example #2
0
def test_postgres_load():
    assert normalize(copy_command('postgresql', tbl, csv)) == normalize("""
    COPY my_table from '%s'
        (FORMAT csv,
         DELIMITER E',',
         NULL '',
         QUOTE '"',
         ESCAPE '\\',
         HEADER True,
         ENCODING 'utf-8');
    """ % escaped_fn)
Example #3
0
def test_mysql_load():
    result = normalize(copy_command('mysql', tbl, csv))
    expected = normalize("""
            LOAD DATA  INFILE '%s'
            INTO TABLE my_table
            CHARACTER SET utf8
            FIELDS
                TERMINATED BY ','
                ENCLOSED BY '"'
                ESCAPED BY '\\\\'
            LINES TERMINATED BY '%s'
            IGNORE 1 LINES;""" % (escaped_fn,
                                  os.linesep.encode('unicode_escape').decode()))
    assert result == expected
Example #4
0
def test_mysql_load():
    result = normalize(copy_command('mysql', tbl, csv))
    expected = normalize(
        """
            LOAD DATA  INFILE '%s'
            INTO TABLE my_table
            CHARACTER SET utf8
            FIELDS
                TERMINATED BY ','
                ENCLOSED BY '"'
                ESCAPED BY '\\\\'
            LINES TERMINATED BY '%s'
            IGNORE 1 LINES;""" %
        (escaped_fn, os.linesep.encode('unicode_escape').decode()))
    assert result == expected