This topic is locked

Uploading multiple field values to a table from a txt file

3/23/2007 12:27:14 PM
PHPRunner General questions
J
Jay author

Hi,
I want to know if it is possible in any way to do a batch upload of multiple field values into a MySQL table from a text file (import).
I have a table RACE with fields:
race_id autoincrement

race_name varchar(50)

race_date datetime

wind varchar(40)

distance float(4,3)

temperature float(3,2)

race_status varchar(40)

race_comments text

position int(6)

arrival_time time

to_win time

yards_pm float(4,3)

points int(6)

type_id_FK int(3)
Thanks in advance and thanks for this wonderfull application. Can't wait for 3.2
Jay

T
thesofa 3/25/2007

When I need to import large amounts of data into a MYSQL table, I use an SQL file, this can be loaded in either via the command line interface on the sql server machine, or via a utility like Navicat which gives you a terrific GUI for managing mysql databases.

the SQL file takes this form

/

MySQL Data Transfer

Source Host: 192.168.0.44

Source Database: det

Target Host: 192.168.0.44

Target Database: det

Date: 25/03/2007 15:05:40

/
SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------

-- Table structure for _printers

-- ----------------------------

CREATE TABLE `_printers` (

`PrinterID` int(11) NOT NULL auto_increment,

`model` varchar(30) NOT NULL,

PRIMARY KEY (`PrinterID`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------

-- Records

-- ----------------------------

INSERT INTO `_printers` VALUES ('1', 'Canon S750');

INSERT INTO `_printers` VALUES ('2', 'Canon BJC5500');

INSERT INTO `_printers` VALUES ('3', 'Canon i865');

INSERT INTO `_printers` VALUES ('4', 'Canon i965');

INSERT INTO `_printers` VALUES ('5', 'Epson Stylus Photo R300');

INSERT INTO `_printers` VALUES ('6', 'HP Colour Laserjet 1500');

INSERT INTO `_printers` VALUES ('7', 'HP Colour Laserjet 2500');

INSERT INTO `_printers` VALUES ('8', 'HP Colour Laserjet 2600N');

INSERT INTO `_printers` VALUES ('9', 'HP Colour Laserjet 4550');

INSERT INTO `_printers` VALUES ('10', 'HP Deskjet 1220');

INSERT INTO `_printers` VALUES ('11', 'HP Deskjet 990c');

INSERT INTO `_printers` VALUES ('12', 'HP Laserjet 1100');

INSERT INTO `_printers` VALUES ('13', 'HP Laserjet 1200');

INSERT INTO `_printers` VALUES ('14', 'HP Laserjet 1300');

INSERT INTO `_printers` VALUES ('15', 'HP Laserjet 2420');

INSERT INTO `_printers` VALUES ('16', 'Kyocera FS1700');

INSERT INTO `_printers` VALUES ('17', 'Kyocera FS1900');

INSERT INTO `_printers` VALUES ('18', 'Kyocera FS1920');

INSERT INTO `_printers` VALUES ('19', 'Kyocera FS8000C');

INSERT INTO `_printers` VALUES ('20', 'Kyocera FSC8008N');


The table is called _printers.

You can see fronm the first part of the file that the table is created fresh each time i run the file.

this Is how I want it.

If you justr want to pull in the data without making the table fresh each time, change the file structure to remove the part I have in red.

you can create the .sql files in a spreadsheet with a little creativity.
In addition, there is this utility I have just found in Googling, here

no idea what it is like, if you try it and its good, tell us all, if you try it and it screws your tables, tell the programmer!
[email="http://www.vbmyadmin.com/index.php?LANGUAGE=EN"]This [/email]page has some free tools for data import too.
HTH

J
Jay author 3/25/2007

Hi and thank you for the tip.
Actually I am refering to uploading a file using the upload control within PHPRunner. I used a MySQL application to manage the database that ROCKS! and it is free SQLyog that is very much like navicat.
I have the PHPRunner ADD interface for the table and I want to integrate an upload control to upload the batch text file.

J
Jane 3/26/2007

Jay,
we plan to add import feature in the next PHPRunner version. It will be ready in a month.