Les Schaffer <[EMAIL PROTECTED]> wrote on 07/20/2005 12:06:46 PM: > I am working on a MySQL application where laptops will be collecting > data into local MySQL tables, and then once a week they will be > network-connected to a central server where they will "check in" their > new data and "check out" new assignments for data collection. > > given a set of rows in a set of tables on the laptop, is there any nifty
> way of grabbing their data and inserting/updating these rows into the > server database, other than to do a SELECT on the local connection and > then turn around and create an INSERT or UPDATE SQL command on the > remote connection with the same data to push data onto server? same for > remote-to-laptop. > > due to the nature of the application, laptops will be working on only a > fraction of the total records on the server, so i can not simply copy > the tables on server onto laptop, nor can i copy tables from laptop onto > server, since other laptops will be checking in data too into the same > tables. > > thanks > > les schaffer > Nope, no way around it. Even if you were doing MySQL replication, the slave computers read and process the SQL statements that affect data on the master (INSERT, UPDATE, and DELETE statements) by reading what MySQL calls the "binary log" or "binlog". Is there a "nifty" way of autogenerating SQL statements? Sure! You could: a) activate binlogging on the laptops then replay the logs to the server using mysqlbinlog (http://dev.mysql.com/doc/mysql/en/mysqlbinlog.html) b) use mysqldump to dump just a few records to SQL ( http://dev.mysql.com/doc/mysql/en/mysqldump.html) and replay those statements to the server (one potential problem with that is that mysqldump only creates INSERT statements) c) Write a program that compares original records (on the server) to the laptop's copies. Update any records on the server not in synch by using your program to create the appropriate SQL statements. That's just off the top of my head. I am sure there are other ways out there. Personally I would go with C) as it would give me the most control over what is and isn't transferred during any "synch" event. This is particularly true as you need to somehow allow the user to "swap out" what they were working on for new data (and mark the new data on the server as "checked out"). The other methods are too "basic" to help you there. Shawn Green Database Administrator Unimin Corporation - Spruce Pine