473,394 Members | 1,709 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,394 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 1465
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.