473,396 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Updating DB Locally

I have a database on my local machine that I make entries and
corrections on. I'd like to be able to upload that to my server and have
that update the database that's on the server. What I've been doing is
saving the local file as a backup. Then I have to edit the backup,
deleting the create file info and all previously uploaded entries before
I can import the text file to the server.

Is there an easier way to do this so I won't get duplicate entry
notices. I'd like the info from my local file to overwrite the server
file like FTPing a new web page will overwrite the old one. Is this
possible to do with mySQL?

Jul 17 '05 #1
7 2472
Paige wrote:
I have a database on my local machine that I make entries and
corrections on. I'd like to be able to upload that to my server and have
that update the database that's on the server. What I've been doing is
saving the local file as a backup. Then I have to edit the backup,
deleting the create file info and all previously uploaded entries before
I can import the text file to the server.

Is there an easier way to do this so I won't get duplicate entry
notices. I'd like the info from my local file to overwrite the server
file like FTPing a new web page will overwrite the old one. Is this
possible to do with mySQL?


First, you have not given enough information to give you the proper
response.

What platform (specifically the OS)

Are the corrections/changes DDL (table/column definitions) or DML
(insert/update/delete)?

Is the data in the database static (read w/occasional updates) or is it
a read/write database (new information stored daily).

I take it that your "local machine" is a test system and the other is
"production"

If you do not care what is in your production database and it gets
over-written with the new version:

Backup/Restore your database from one place to another...

http://www.phpbb.com/phpBB/viewtopic.php?t=9963

Michael Austin.

PS -- I would backup the "production" database for safe keeping before
trying this...

Jul 17 '05 #2
Michael Austin wrote:
Paige wrote:
I have a database on my local machine that I make entries and
corrections on. I'd like to be able to upload that to my server and
have that update the database that's on the server. What I've been
doing is saving the local file as a backup. Then I have to edit the
backup, deleting the create file info and all previously uploaded
entries before I can import the text file to the server.

Is there an easier way to do this so I won't get duplicate entry
notices. I'd like the info from my local file to overwrite the server
file like FTPing a new web page will overwrite the old one. Is this
possible to do with mySQL?

First, you have not given enough information to give you the proper
response.

What platform (specifically the OS)


Win XP
Are the corrections/changes DDL (table/column definitions) or DML
(insert/update/delete)?
I guess they'd be DML. Nothing changes as to columns or definitions. The
only thing that might change would be the info already stored in an
entrylike if someone was to move and change their address, that sort of
thing. And of course, the new version that I would want to upload would
have more total entries than the old one.
Is the data in the database static (read w/occasional updates) or is it
a read/write database (new information stored daily).
static
I take it that your "local machine" is a test system and the other is
"production"
I guess that's a fair assessment. I want to do the work on my WinXP,
then upload the table to the server to replace what is there so I don't
have to be online when I want to work on the database.
If you do not care what is in your production database and it gets
over-written with the new version: Backup/Restore your database from one place to another...

http://www.phpbb.com/phpBB/viewtopic.php?t=9963


Thank you for this suggestion and maybe it's me but this thread seems to
involve backing up and restoring phpbb databases on a *new* server/host.
If that was my situation, I would have no problem as there would be no
entries on the new server so there couldn't be any duplicate ones in the
upload. But it's the same table on the same server that I'm looking to
do with the new one overwriting the old one.

Jul 17 '05 #3
Paige wrote:
Michael Austin wrote:
Paige wrote:
I have a database on my local machine that I make entries and
corrections on. I'd like to be able to upload that to my server and
have that update the database that's on the server. What I've been
doing is saving the local file as a backup. Then I have to edit the
backup, deleting the create file info and all previously uploaded
entries before I can import the text file to the server.

Is there an easier way to do this so I won't get duplicate entry
notices. I'd like the info from my local file to overwrite the server
file like FTPing a new web page will overwrite the old one. Is this
possible to do with mySQL?


First, you have not given enough information to give you the proper
response.

What platform (specifically the OS)

Win XP
Are the corrections/changes DDL (table/column definitions) or DML
(insert/update/delete)?

I guess they'd be DML. Nothing changes as to columns or definitions. The
only thing that might change would be the info already stored in an
entrylike if someone was to move and change their address, that sort of
thing. And of course, the new version that I would want to upload would
have more total entries than the old one.
Is the data in the database static (read w/occasional updates) or is
it a read/write database (new information stored daily).

static
I take it that your "local machine" is a test system and the other is
"production"

I guess that's a fair assessment. I want to do the work on my WinXP,
then upload the table to the server to replace what is there so I don't
have to be online when I want to work on the database.
If you do not care what is in your production database and it gets
over-written with the new version:


Backup/Restore your database from one place to another...

http://www.phpbb.com/phpBB/viewtopic.php?t=9963

Thank you for this suggestion and maybe it's me but this thread seems to
involve backing up and restoring phpbb databases on a *new* server/host.
If that was my situation, I would have no problem as there would be no
entries on the new server so there couldn't be any duplicate ones in the
upload. But it's the same table on the same server that I'm looking to
do with the new one overwriting the old one.

If users of the "production" database can change their information and
you make different changes to your "local" database, then you must
guarantee that one does not overwrite the other. Basically you need to
be able to synchronize your databases not overwrite them... true? Next
question is this just one table or multiple tables?
Michael.
Jul 17 '05 #4
Michael Austin wrote:
Paige wrote:
Michael Austin wrote:
Paige wrote:

I have a database on my local machine that I make entries and
corrections on. I'd like to be able to upload that to my server and
have that update the database that's on the server. What I've been
doing is saving the local file as a backup. Then I have to edit the
backup, deleting the create file info and all previously uploaded
entries before I can import the text file to the server.

Is there an easier way to do this so I won't get duplicate entry
notices. I'd like the info from my local file to overwrite the
server file like FTPing a new web page will overwrite the old one.
Is this possible to do with mySQL?
First, you have not given enough information to give you the proper
response.

What platform (specifically the OS)


Win XP
Are the corrections/changes DDL (table/column definitions) or DML
(insert/update/delete)?


I guess they'd be DML. Nothing changes as to columns or definitions.
The only thing that might change would be the info already stored in
an entrylike if someone was to move and change their address, that
sort of thing. And of course, the new version that I would want to
upload would have more total entries than the old one.
Is the data in the database static (read w/occasional updates) or is
it a read/write database (new information stored daily).


static
I take it that your "local machine" is a test system and the other is
"production"


I guess that's a fair assessment. I want to do the work on my WinXP,
then upload the table to the server to replace what is there so I
don't have to be online when I want to work on the database.
If you do not care what is in your production database and it gets
over-written with the new version:

Backup/Restore your database from one place to another...

http://www.phpbb.com/phpBB/viewtopic.php?t=9963


Thank you for this suggestion and maybe it's me but this thread seems
to involve backing up and restoring phpbb databases on a *new*
server/host. If that was my situation, I would have no problem as
there would be no entries on the new server so there couldn't be any
duplicate ones in the upload. But it's the same table on the same
server that I'm looking to do with the new one overwriting the old one.

If users of the "production" database can change their information and
you make different changes to your "local" database, then you must
guarantee that one does not overwrite the other. Basically you need to
be able to synchronize your databases not overwrite them... true? Next
question is this just one table or multiple tables?


I am the only one that changes the database entries. There is no form
info being directly submitted to the db and no one else touches it. So
at all times, the db on my computer is the most up-to-date one.

I'm sorry but I don't know the difference between overwriting and
synchronizing a database. I only know that I'd like to be able to upload
the latest db info from my computer to the server and have that one
overwrite, replace, update (or whatever terminology fits) the one that's
on the server.

As it stands right now, the only way I can accomplish this is to either
drop the entire server database and reinstall it using the updated copy
or else I have to edit all the entries in the .sql backup I make to
delete existing entries and mark the ones I changed as UPDATE instead of
INSERT. Neither way is particularly appealing, thus my inquiry as to an
easieer way to do this.

Jul 17 '05 #5
>I am the only one that changes the database entries. There is no form
info being directly submitted to the db and no one else touches it. So
at all times, the db on my computer is the most up-to-date one.

I'm sorry but I don't know the difference between overwriting and
synchronizing a database.
If the "production" database is truly read-only, there is no difference.

If there are modifications to both databases (say, there is a 'last
used' field changed when a user accesses the web site, or the user
can change his/her password), then you have to merge the changes
for true synchronization, and overwriting just wipes out all the
changes made in the production database from the web and replaces
them from the master copy. Real synchronization requires intelligent
information about what fields are updated on which database for
what purpose. And if the tables are designed poorly, it may be
impossible to do right at all. Overwriting is always possible
(assuming the system is up and you don't run out of disk space,
etc.) but in practice it may be a disaster (lost updates).

Since your updates seem to be entered in one place only, you might
consider setting up replication if you are willing to have changes
made on the test server appear almost instantly on the production
server (which could ruin its use as a 'test' server, or it might
just eliminate the chore of propagating updates entirely).
I only know that I'd like to be able to upload
the latest db info from my computer to the server and have that one
overwrite, replace, update (or whatever terminology fits) the one that's
on the server.
I'd look at various options of mysqldump. You don't have to delete
and re-create the tables if the schema didn't change (-t, no table
creation info). You can also lock the tables so all the updates
get done, from the point of view of the web server, all at once.
As it stands right now, the only way I can accomplish this is to either
drop the entire server database and reinstall it using the updated copy
or else I have to edit all the entries in the .sql backup I make to
delete existing entries and mark the ones I changed as UPDATE instead of
INSERT. Neither way is particularly appealing, thus my inquiry as to an
easieer way to do this.


I don't understand why ignoring warnings about inserting duplicate
keys is a problem. I'm presuming that you have UNIQUE keys set up
so re-inserting the same data you already have won't result in
duplicate records. The mysql command-line utility has the -f option,
keep going on SQL error, which will take care of stopping on hitting
an already-existing record.

mysqldump also permits adding a WHERE clause to the data you dump,
so if there is a time stamp (or some other means you can identify
new records, like an autoincrement sequence number if you only ADD
new records and never change existing ones) on the records, you can
just dump stuff since the last dump and load those. Of course you
have to keep track of this info for the next dump/copy.

Is the volume of data such that uploading all of it each time is a
problem?

Gordon L. Burditt
Jul 17 '05 #6
Gordon Burditt wrote:
I am the only one that changes the database entries. There is no form
info being directly submitted to the db and no one else touches it. So
at all times, the db on my computer is the most up-to-date one.

I'm sorry but I don't know the difference between overwriting and
synchronizing a database.

If the "production" database is truly read-only, there is no difference.

If there are modifications to both databases (say, there is a 'last
used' field changed when a user accesses the web site, or the user
can change his/her password), then you have to merge the changes
for true synchronization, and overwriting just wipes out all the
changes made in the production database from the web and replaces
them from the master copy. Real synchronization requires intelligent
information about what fields are updated on which database for
what purpose. And if the tables are designed poorly, it may be
impossible to do right at all. Overwriting is always possible
(assuming the system is up and you don't run out of disk space,
etc.) but in practice it may be a disaster (lost updates).


But as I said, there is no writing done to the database on the server at
all. It does not contain users/passwords. It contains information only
and is not used as any part of a login system. The only copy that
changes if the one on my computer. When I have finished making those
changes, I need a streamlined way to upload them from my computer to the
server which is not mine.
Since your updates seem to be entered in one place only, you might
consider setting up replication if you are willing to have changes
made on the test server appear almost instantly on the production
server (which could ruin its use as a 'test' server, or it might
just eliminate the chore of propagating updates entirely).
Where would I find out more about this method?
I only know that I'd like to be able to upload
the latest db info from my computer to the server and have that one
overwrite, replace, update (or whatever terminology fits) the one that's
on the server.

I'd look at various options of mysqldump. You don't have to delete
and re-create the tables if the schema didn't change (-t, no table
creation info). You can also lock the tables so all the updates
get done, from the point of view of the web server, all at once.

As it stands right now, the only way I can accomplish this is to either
drop the entire server database and reinstall it using the updated copy
or else I have to edit all the entries in the .sql backup I make to
delete existing entries and mark the ones I changed as UPDATE instead of
INSERT. Neither way is particularly appealing, thus my inquiry as to an
easieer way to do this.

I don't understand why ignoring warnings about inserting duplicate
keys is a problem. I'm presuming that you have UNIQUE keys set up
so re-inserting the same data you already have won't result in
duplicate records. The mysql command-line utility has the -f option,
keep going on SQL error, which will take care of stopping on hitting
an already-existing record.


I don't have command line access to the server database, only to the
copy on my computer. The duplicate entries is a problem because
sometimes the info in a specific entry changes (people move, change
phone numbers, marry, etc) and I need the new info to overwrite or
somehow supplant the old when I upload my changes. The db only has 5
fields and the primary is the auto incrementing ID.
mysqldump also permits adding a WHERE clause to the data you dump,
so if there is a time stamp (or some other means you can identify
new records, like an autoincrement sequence number if you only ADD
new records and never change existing ones) on the records, you can
just dump stuff since the last dump and load those. Of course you
have to keep track of this info for the next dump/copy.
I understand that part. Adding the new fields only is easy enough even
using my backup file, open file, edit file, save file, upload file
method. It's the fields that changed that are more work. I'll have to
read more on mysqldump to see if it's something I can use or adapt.
Is the volume of data such that uploading all of it each time is a
problem?


Well there are over 700 entries in it right now and it's still growing.

Jul 17 '05 #7
Paige wrote:
Gordon Burditt wrote:
I am the only one that changes the database entries. There is no form
info being directly submitted to the db and no one else touches it.
So at all times, the db on my computer is the most up-to-date one.

I'm sorry but I don't know the difference between overwriting and
synchronizing a database.


If the "production" database is truly read-only, there is no difference.

If there are modifications to both databases (say, there is a 'last
used' field changed when a user accesses the web site, or the user
can change his/her password), then you have to merge the changes
for true synchronization, and overwriting just wipes out all the
changes made in the production database from the web and replaces
them from the master copy. Real synchronization requires intelligent
information about what fields are updated on which database for
what purpose. And if the tables are designed poorly, it may be
impossible to do right at all. Overwriting is always possible
(assuming the system is up and you don't run out of disk space,
etc.) but in practice it may be a disaster (lost updates).

But as I said, there is no writing done to the database on the server at
all. It does not contain users/passwords. It contains information only
and is not used as any part of a login system. The only copy that
changes if the one on my computer. When I have finished making those
changes, I need a streamlined way to upload them from my computer to the
server which is not mine.
Since your updates seem to be entered in one place only, you might
consider setting up replication if you are willing to have changes
made on the test server appear almost instantly on the production
server (which could ruin its use as a 'test' server, or it might
just eliminate the chore of propagating updates entirely).

Where would I find out more about this method?
I only know that I'd like to be able to upload the latest db info
from my computer to the server and have that one overwrite, replace,
update (or whatever terminology fits) the one that's on the server.


I'd look at various options of mysqldump. You don't have to delete
and re-create the tables if the schema didn't change (-t, no table
creation info). You can also lock the tables so all the updates
get done, from the point of view of the web server, all at once.

As it stands right now, the only way I can accomplish this is to
either drop the entire server database and reinstall it using the
updated copy or else I have to edit all the entries in the .sql
backup I make to delete existing entries and mark the ones I changed
as UPDATE instead of INSERT. Neither way is particularly appealing,
thus my inquiry as to an easieer way to do this.


I don't understand why ignoring warnings about inserting duplicate
keys is a problem. I'm presuming that you have UNIQUE keys set up
so re-inserting the same data you already have won't result in
duplicate records. The mysql command-line utility has the -f option,
keep going on SQL error, which will take care of stopping on hitting
an already-existing record.

I don't have command line access to the server database, only to the
copy on my computer. The duplicate entries is a problem because
sometimes the info in a specific entry changes (people move, change
phone numbers, marry, etc) and I need the new info to overwrite or
somehow supplant the old when I upload my changes. The db only has 5
fields and the primary is the auto incrementing ID.
mysqldump also permits adding a WHERE clause to the data you dump,
so if there is a time stamp (or some other means you can identify
new records, like an autoincrement sequence number if you only ADD
new records and never change existing ones) on the records, you can
just dump stuff since the last dump and load those. Of course you
have to keep track of this info for the next dump/copy.

I understand that part. Adding the new fields only is easy enough even
using my backup file, open file, edit file, save file, upload file
method. It's the fields that changed that are more work. I'll have to
read more on mysqldump to see if it's something I can use or adapt.
Is the volume of data such that uploading all of it each time is a
problem?

Well there are over 700 entries in it right now and it's still growing.

There was an entry recently that had the title "How to copy mysql tables
between two servers?" in this ng. It was ugly, but it appeared to work...

I am guessing you want this update to be somewhat automagic at some
really early hour in the morning...

This is what I would do...

add a column to your "master" database (local) called updatetime of type
date and initdate of type date.

extract data where updatetime = initdate and updatetime > yesterday...
create insert statements for these

extract data where updatetime > yesterday and initdate < yesterday -
create update statements for these...

** yesterday = 00:00 what ever the day before today is...

like:
mysql> select * from t;
+-----------+------------+------------+
| d | initdate | updatedate |
+-----------+------------+------------+
| today | 2004-06-21 | 2004-06-21 |
| not today | 2004-01-01 | 2004-06-21 |
| yesterday | 2004-06-19 | 2004-06-20 |
+-----------+------------+------------+
3 rows in set (0.01 sec)

!!!!!!!!!!!! UPDATES !!!!!!!!!!!!!!!!!!!!
mysql> select * from t where updatedate=curdate() and initdate <> curdate();
+-----------+------------+------------+
| d | initdate | updatedate |
+-----------+------------+------------+
| not today | 2004-01-01 | 2004-06-21 |
+-----------+------------+------------+
1 row in set (0.00 sec)

!!!!!!!!!!!!! INSERTS !!!!!!!!!!!!!!
mysql> select * from t where updatedate=curdate() and initdate = curdate();
+-------+------------+------------+
| d | initdate | updatedate |
+-------+------------+------------+
| today | 2004-06-21 | 2004-06-21 |
+-------+------------+------------+
1 row in set (0.01 sec)
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Luc Dal | last post by:
Hello, Is it possible for a client to update an excel worksheet sheet online ? Thanks for your reply Luc
7
by: Frostillicus | last post by:
Hi, I've written some javascript to randomly choose a classical music composer's picture and sample audio and display it on my home page (http://marc.fearby.com/), and this works fine in Mozilla...
1
by: gaosul | last post by:
I am non-programming scientist and I am using a Program called Easyarticles from Synaptosoft Inc., which is based the database program Access. Unfortunately, the owner of this company has...
1
by: Jim | last post by:
I have a dataset-bound datagrid and, when the user adds a row to the datagrid and fills it with the data, I'd like to be able to update the dataset (with the newly-added row) and then the database...
2
by: Tim Bird | last post by:
I am writing SQL enterprise type application in c# and allowing ht user to execute queries, etc. The results are displayed in a grid using data adapteres, etc. Do I really have to write routines to...
1
by: VB Programmer | last post by:
I have a winform app that I want to auto-update whenever there is a new version on the web server. I realize that I can have a shortcut pointing to, for example, http://locahost/myweb/MyApp.exe....
0
by: scorpion74 | last post by:
Hi All I am developing a very complex application that hosts UserControl in IE Browser.Usercontrol has treeview and datagrid control basically.The data is in xml file and which is hierarchical...
2
by: Commander Ace | last post by:
Hi, I'm having some problems with updating an SQL Database with modified fields from a datatable. I got the code from a Wrox book, 'Professional VB.NET 2003', the same code can be found here:...
3
by: Grant | last post by:
I need some sample code showing how to manipulate data in my access database using C#. This is what Im trying to do: Dropdownlist with datagrid both bound to datasource. When the drop down list...
0
by: CDZ | last post by:
I'm a bit confused on OutputCache when used in a .ascx page. I have a control that reads in an RSS feed from an external source and I would like to cache that server-side so that any visitors get a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.