472,958 Members | 2,587 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

updating db with csv

#1 If any one familiar with godaddy hosting. They have apparently have
a hosing server i.e.(scripts, html files etc.), and a server for
databases. How can I import from my script, with a csv. if the db is
on a different server than the script server.

#2 I would like to update and insert with the same csv file. Is there
a way to tell the database for some lines to update, and for some
lines to insert.

Jun 7 '07 #1
4 1457
mo**********@gmail.com wrote:
>
#1 If any one familiar with godaddy hosting. They have apparently have
a hosing server i.e.(scripts, html files etc.), and a server for
databases. How can I import from my script, with a csv. if the db is
on a different server than the script server.
What does this have to do with either Python or MySQL?

When you connect to the database, you have to specify a hostname. As long
as you provide the right one, it doesn't matter where your script runs.
>#2 I would like to update and insert with the same csv file. Is there
a way to tell the database for some lines to update, and for some
lines to insert.
Not in standard SQL. MySQL supports a REPLACE extension that does an
UPDATE if the key already exists, and an INSERT if it does not. There is
also an extension clause to the INSERT statement called "ON DUPLICATE KEY
UPDATE xxx" that might do what you want.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jun 11 '07 #2
On 11 Jun, 07:37, Tim Roberts <t...@probo.comwrote:
| Not in standard SQL. MySQL supports a REPLACE extension that does
an
| UPDATE if the key already exists, and an INSERT if it does not.
There is
| also an extension clause to the INSERT statement called "ON
DUPLICATE KEY
| UPDATE xxx" that might do what you want.
| --
| Tim Roberts, t...@probo.com
| Providenza & Boekelheide, Inc.

No Tim, that is not correct. the REPLACE extension does not do an
update, it does a replace. It delets the old record and inserts a new
one. The INSERT...ON DUPLICATE KEY UPDATE... does an update. So a
REPLACE will remove all existing field values not referenced in the
statement, whilst an INSERT...ON DUPLICATE KEY UPDATE... will preserve
them. Also REPLACE will make a TIMESTAMP column which has a DEFAULT
CURRENT_TIMESTAMP setting work like one which has ON UPDATE
CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP setting.

Jun 11 '07 #3
Captain Paralytic <pa**********@yahoo.comwrote:
>On 11 Jun, 07:37, Tim Roberts <t...@probo.comwrote:
| Not in standard SQL. MySQL supports a REPLACE extension that does
| an UPDATE if the key already exists, and an INSERT if it does not.
| There is also an extension clause to the INSERT statement called
| "ON DUPLICATE KEY UPDATE xxx" that might do what you want.

No Tim, that is not correct. the REPLACE extension does not do an
update, it does a replace. It delets the old record and inserts a new
one. The INSERT...ON DUPLICATE KEY UPDATE... does an update. So a
REPLACE will remove all existing field values not referenced in the
statement, whilst an INSERT...ON DUPLICATE KEY UPDATE... will preserve
them. Also REPLACE will make a TIMESTAMP column which has a DEFAULT
CURRENT_TIMESTAMP setting work like one which has ON UPDATE
CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP setting.
Thanks for the correction; that's an important difference. I'm a Postgres
guy; if I had noticed this was cross-posted to c.d.mysql as well as
comp.lang.python, I probably would have kept quiet.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jun 13 '07 #4
On 13 Jun, 06:35, Tim Roberts <t...@probo.comwrote:
Captain Paralytic <paul_laut...@yahoo.comwrote:
On 11 Jun, 07:37, Tim Roberts <t...@probo.comwrote:
| Not in standard SQL. MySQL supports a REPLACE extension that does
| an UPDATE if the key already exists, and an INSERT if it does not.
| There is also an extension clause to the INSERT statement called
| "ON DUPLICATE KEY UPDATE xxx" that might do what you want.
No Tim, that is not correct. the REPLACE extension does not do an
update, it does a replace. It delets the old record and inserts a new
one. The INSERT...ON DUPLICATE KEY UPDATE... does an update. So a
REPLACE will remove all existing field values not referenced in the
statement, whilst an INSERT...ON DUPLICATE KEY UPDATE... will preserve
them. Also REPLACE will make a TIMESTAMP column which has a DEFAULT
CURRENT_TIMESTAMP setting work like one which has ON UPDATE
CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP setting.

Thanks for the correction; that's an important difference. I'm a Postgres
guy; if I had noticed this was cross-posted to c.d.mysql as well as
comp.lang.python, I probably would have kept quiet.
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
But then you wouldn't have learned about this important difference. I
too learn a lot when I give what I think is a correct answer and then
have someone else explain what really happens.

The wonder of usenet.

Jun 13 '07 #5

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

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
2
by: Hal Vaughan | last post by:
First, I am aware of both SwingUtilities.invokeLater(), and of using Thread to create a new thread.  These are part of the problem. I want to have something running in the background, while the...
45
by: It's me | last post by:
I am new to the Python language. How do I do something like this: I know that a = 3 y = "a" print eval(y)
6
by: Hennie de Nooijer | last post by:
Hi, Currently we're a building a metadatadriven datawarehouse in SQL Server 2000. We're investigating the possibility of the updating tables with enormeous number of updates and insert and the...
0
by: cwbp17 | last post by:
Have two tables that have a FK relationship on ID column. Have one datagrid that displays all of the columns of both tables. What's the best approach on updating a row from the datagrid back to...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
14
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
6
by: muttu2244 | last post by:
hi all am updating the same file in ftp, through multiple clients, but am scared that two clients may open the same file at a time, and try updating, then the data updated by one data will be...
0
by: =?Utf-8?B?YmFrZXJzaGFjaw==?= | last post by:
Unless my app is EXTREMELY simple, I get the cross-threading error message regularly when updating controls on a Windows form. My latest example involves a dll that runs a System.Threading.Timer,...
5
by: rosaryshop | last post by:
I'm working a jewelry/rosary design web site at http://www.rosaryshop.com/rosariesAndKits2.php. As the user makes selections, it updates images of various parts, giving them a preview of the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.