Help with debug

Discussion in 'MySQL' started by theblade24, Nov 8, 2006.

  1. #1
    I run this little script to get a csv file into an sql database quickly

    At the end of the process in putty, it displays what is going on........records, deleted, skipped, warnings.

    Is it possible to amend this script to also display whatever the warning is if there are any to help me track it down and fix? Like row, field, etc etc or something to tell me where the warning is?

    It seems there is debug info written in it but I never can find the debug file so I don't think it is working properly.

    The script is below:

    #!/bin/sh

    # Simple script to import the product.csv file

    SRC=/home/XXXXXX/public_html/shop/data/tables/product.csv
    CSVFILE=/tmp/product.csv
    DB=XXXXXX_ias4uproducts

    # make sure the source file exists
    if [ ! -f $SRC ]; then
    echo "Can't find $SRC"
    exit 1
    fi

    # copy the file to /tmp for processing
    [ -f $SRC ] || exit "Can't find $SRC"
    cp -f $SRC $CSVFILE


    # delete old data
    echo Deleting all records from $DB.product
    echo "delete from product;" | mysql --user=XXXXXX --password=XXXXXX $DB

    # import
    #echo Importing to the $DB database from $CSVFILE
    #mysqlimport --user=XXXXXX --password=XXXXXX $DB --lines-terminated-by="\r\n" --fields-terminated-by="," --fields-optionally-enclosed-by='"' \
    # --replace --ignore-lines=1 --verbose $CSVFILE

    # debug useless without support for it compiled into mysql
    mysqlimport --user=XXXXXX --password=XXXXXX $DB --lines-terminated-by="\r\n" --fields-terminated-by="," --fields-optionally-enclosed-by='"' \
    --replace --ignore-lines=1 --verbose --debug='d:t:eek:,update.debug.out' $CSVFILE

    # cleanup
    rm -f $CSVFILE

    exit 0
     
    theblade24, Nov 8, 2006 IP