mysql++ load local infile

View: New views
3 Messages — Rating Filter:   Alert me  

mysql++ load local infile

by Dennis M. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am using mysql++ to access mySQL from a C++ program.

I am able execute various queries except LOAD DATA LOCAL INFILE.

How do I go about doing this? I have not seen an implementation in any of the examples provided in the mysql++ download.

This is what I am doing right now:

#define HOST "localhost"
#define DB "databse_name"
#define USER "anonymous"
#define PASS ""

.
.
.

mysqlpp::Connection con(DB, HOST, USER, PASS);
mysqlpp::NoExceptions ne(con);
mysqlpp::Query query = con.query();

CString command;
command = "LOAD DATA LOCAL INFILE \"file_location\" into TABLE name_of_table;";
query = con.query(command);
query.execute();



Is there anything else that needs to be done for this to work, or do I have my query set up incorrectly?


Thanks!

_________________________________________________________________
Need to know now? Get instant answers with Windows Live Messenger.
http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_062008

Re: mysql++ load local infile

by John Gehring :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What exactly is failing with your program?

I do this:

    try {
        ...
        string statement = "load data infile '" + fullFileName;
        statement += "' into table daytypes ";
        statement += "fields terminated by ',' enclosed by '' ";
        statement += "lines terminated by '\\r\\n'";
        executeSQLStatement(statement);
    }
    catch (const mysqlpp::Exception& er) {
        ...stuff
    }

executeSQLStatement() simply invokes:

        mysqlpp::Query query = mySQLConn->query();
        query << SQLStatement;
        query.execute();

I'd have to double check, but I believe that it is important that the
slashes in the file name are forward slashes.



Dennis M. wrote:

> I am using mysql++ to access mySQL from a C++ program.
>
> I am able execute various queries except LOAD DATA LOCAL INFILE.
>
> How do I go about doing this? I have not seen an implementation in any of the examples provided in the mysql++ download.
>
> This is what I am doing right now:
>
> #define HOST "localhost"
> #define DB "databse_name"
> #define USER "anonymous"
> #define PASS ""
>
> .
> .
> .
>
> mysqlpp::Connection con(DB, HOST, USER, PASS);
> mysqlpp::NoExceptions ne(con);
> mysqlpp::Query query = con.query();
>
> CString command;
> command = "LOAD DATA LOCAL INFILE \"file_location\" into TABLE name_of_table;";
> query = con.query(command);
> query.execute();
>
>
>
> Is there anything else that needs to be done for this to work, or do I have my query set up incorrectly?
>
>
> Thanks!
>
> _________________________________________________________________
> Need to know now? Get instant answers with Windows Live Messenger.
> http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_062008
>  

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:    http://lists.mysql.com/plusplus?unsub=lists@...


Parent Message unknown RE: mysql++ load local infile

by Dennis M. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just wanted to say thanks. My problem had to do with using backslashes instead of forward slashes. I was using \\ instead of /
_________________________________________________________________
The other season of giving begins 6/24/08. Check out the i’m Talkathon.
http://www.imtalkathon.com?source=TXT_EML_WLH_SeasonOfGiving
LightInTheBox - Buy quality products at wholesale price