[Gllug] Importing data into MySQL
Liam Delahunty
liamvictor at gmail.com
Sun Jul 25 23:05:36 UTC 2004
On Sun, 25 Jul 2004 09:53:55 -0700 (PDT), Tom Schutzer-Weissmann
<trmsw at yahoo.co.uk> wrote:
> --- Mark Preston <mark at markpreston.co.uk> wrote:
> [...]
> > I only have a
> > rudimentary grasp of MySQL and the commands below
> > will restore the
> > details, but at the expense of overwriting any
> > existing details held in
> > the database. Ideally I would like to update and
> > install new records
> > whilst preserving other existing records on the
> > reception computer.
>
You can avoid mysqldump and go straight for mysql
Lets say your form produces a file called insert.sql
with data such as
INSERT INTO patients VALUES ('whatever', 'that' ....);
Then to run it:
/usr/bin/mysql -uusername -ppassword databasename <
/path/to/insert.sql > /tmp/myoutput.tab
Now, this will only insert the data, it won't update any, just add new
ones. I can't think of a way of doing it in pure MySQL. You could use
a scripting language to check for a unique key, such as the NHSno, and
update the record if it exists.
Another method might be to write the original data file as a TAB, then
use a script to update/insert depending on if the records are already
in the db.
--
Kind regards, Liam Delahunty
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list