MySQLdb, lots of columns and newb-ness

Felix Benner felix.benner at imail.de
Wed Dec 20 00:57:17 EST 2006


Andrew Sackville-West schrieb:

> I have an ascii data dump from a POS system that has 131 fields in a
> single column in a flat file. I can easily open the file, read in the
> data and assemble it into various formats. okay. what I *want* to do
> is insert each of these fields into a mysql database that has 132
> columns that correspond to the 131 fields in the ascii file (plus one
> for the date).
> 
> I can successfully connect to mysql and do stuff to my tables my
> specific problem is how to efficiently put those 132 fields into the
> thing. All I have been able to figure out is really ugly stuff like:
> build the mysql statement out of various pieces with appropriate
> commas and quote included. stuff like (not tested)


Haven't tested it, but maybe
http://dev.mysql.com/doc/refman/5.0/en/load-data.html is your friend.



More information about the Python-list mailing list