Professional Web Applications Themes

LOAD DATA INFILE problem - MySQL

Consider the following table and csv file: ------------------------------------------- CREATE TABLE `table_test` ( `c1` VARCHAR( 255 ) NOT NULL , `c2` VARCHAR( 255 ) NOT NULL ) ENGINE = innodb; ------------------------------------------- data.csv ------------------------------------------- "row_1 col_1", "row_1 col_2 " "row_2 col_1", "row_2 col_2" "row_3 col_1", "row_3 col_2" ------------------------------------------- I import to MySQL using: LOAD DATA LOCAL INFILE 'c:/data.csv' INTO TABLE `table_test` FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\' LINES TERMINATED BY '\r\n' The result is not what I want. How to make the data import work? Since the field is already enclosed by `"`, and I do not want ...

  1. #1

    Default LOAD DATA INFILE problem

    Consider the following table and csv file:

    -------------------------------------------
    CREATE TABLE `table_test` (
    `c1` VARCHAR( 255 ) NOT NULL ,
    `c2` VARCHAR( 255 ) NOT NULL
    ) ENGINE = innodb;
    -------------------------------------------
    data.csv
    -------------------------------------------
    "row_1 col_1", "row_1 col_2


    "
    "row_2 col_1", "row_2 col_2"
    "row_3 col_1", "row_3 col_2"
    -------------------------------------------

    I import to MySQL using:

    LOAD DATA LOCAL INFILE 'c:/data.csv' INTO TABLE `table_test` FIELDS
    TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY
    '\r\n'

    The result is not what I want.

    How to make the data import work?
    Since the field is already enclosed by `"`, and I do not want to remove
    the line break or carriage return in the data.

    Thanks.

    howachen@gmail.com Guest

  2. #2

    Default load data infile problem

    does any one know why when I execute this mysql statement with python
    api

    LOAD DATA INFILE 'data.txt' INTO TABLE merchandise;

    I get this error and how can I fix it

    #1045 - Access denied for user: 'papermen%' (Using password: YES)

    moishyyehuda@gmail.com Guest

  3. #3

    Default Re: load data infile problem

    com wrote: 

    This has nothing to do with Python. It is obvious from the error that
    the user "papermen" doesn't have the privileges to load data into that
    table. Ask your database administrator to give you the appropriate
    privileges.

    Followups set.
    --
    Michael Hoffman
    Michael Guest

  4. #4

    Default Re: load data infile problem

    On Sun, 10 Jun 2007 16:38:17 -0000, com declaimed the
    following in comp.lang.python:
     

    Show us the code....


    Off-hand; the administrator of the database system did not grant
    "load data" privileges (FILE privilege) to the account with which you
    are connecting. Also, in the format given, "data.txt" needs to be stored
    on the server in the directory of the database itself (as I recall).

    If the file is local, and you are connecting to a remote server, you
    don't need FILE privilege, but you will need to specify the LOCAL
    keyword in the LOAD DATA statement.


    --
    Wulfraed Dennis Lee Bieber KD6MOG
    netcom.com com
    HTTP://wlfraed.home.netcom.com/
    (Bestiaria Support Staff: com)
    HTTP://www.bestiaria.com/
    Dennis Guest

Similar Threads

  1. LOAD DATA INFILE
    By Luca in forum MySQL
    Replies: 4
    Last Post: July 11th, 12:35 PM
  2. Complex LOAD DATA INFILE
    By stefaan.lhermitte@agr.kuleuven.ac.be in forum MySQL
    Replies: 6
    Last Post: May 18th, 06:34 PM
  3. Load Data Infile question
    By bradfordh@gmail.com in forum MySQL
    Replies: 3
    Last Post: March 23rd, 04:53 AM
  4. help : LOAD DATA LOCAL INFILE
    By Dave in forum PHP Development
    Replies: 3
    Last Post: October 5th, 12:22 AM
  5. Problem with "LOAD DATA INFILE"
    By Andreas Emmert in forum PHP Development
    Replies: 1
    Last Post: August 24th, 03:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139