Hello,
The gist of my problem is this: I load data from a CSV file into a table.
The fields are unquoted. I then read back parts of this table to create a
new table. The problem is that the table that gets created is requiring
backticks because the import of data from a table to create another table is
quoting.
Let me explain via code:
// load data from CSV file into property_map table
q << "load data infile '/home/matt/map.csv' into table property_map fields
terminated by ',' ";
q << "select * from property_map";
Result res = q.store();
q.reset();
q << "create table property_temp( ";
Row row;
Row::size_type i;
for (i=0; row = res.at(i); ++i)
{
// notice the required backticks
q << "`" << row.at(2) << "` varchar(" << row.at(3) <<
") NOT NULL
default '', ";
}
q << "PRIMARY KEY (`" << res.at(0).at(2) << "`) ) ENGINE=InnoDB;";
q.execute();
-----------
When I do a select * from property_map the fields are all quoted, and in the
mysql client, I have to use backticks to use the fields.
What am I doing wrong?? Is my Load Data command wrong? Is my CSV format
wrong? Am I trying to create the table incorrectly? ( NB: This isn't my
preferred way to create a table. I am forced to use a legacy system that
has there tables set up this way)
Any help is appreciated.
Thanks
Matt
--
View this message in context:
http://www.nabble.com/Quoting-mis-understanding-tf3948838.html#a11202678
Sent from the MySQL - C++ mailing list archive at Nabble.com.