(I'm a long term newbie :) )
I wanted to copy a blob's contents in mysql in python from one record to another.
I had a heck of a time with it, so I wanted to post it for others.
The where clause was the tricky part for me.
It probably has poor syntax, but it works.
(Obviously) it can be used cross table and across db's.
import MySQLdb
con0 = MySQLdb.connect (host="localhos t",user="",pass wd="",db="in")
con1 = MySQLdb.connect (host="localhos t",user="", passwd="", db="in")
sourcefield = 'logo'
sourceid = 2514
# A string
s = 2515
curs0=con0.curs or()
selectstring = "select %s from table where id = %s" % (sourcefield, sourceid)
curs0.execute(s electstring)
sourceresult = curs0.fetchone( )
cursor1 = con1.cursor()
s1 = "update table set "+ sourcefield + " = %s where id = "
s2 = s1 + str(s)
tup = s2
cursor1.execute (tup[::],(sourceresult ))
con0.close()
con1.close() 0 1230 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sams |
last post by:
Iam posting this after trying many tutorials in the NG and failing to
retrieve the blob out of a record. So please bear with me before
before you pull the water hose or flame throwers ......
I can upload a Jpeg image file perfectly. Iam using this snippet to do
that..
<!-- addpic.php snippet !-->
....
$file = fopen($_FILES, "rb");
|
by: sime |
last post by:
Hi,
I have a blob field in a mysql database table. I want to copy a blob
from one record to another. I am having trouble transferring the data
via a php variable. Maybe I need to addslashes or convert to Hex or
something. I've tried a few things but can't quite get it. Here is
simplified code.
mysql_select_db($dbname, $connection);
|
by: hamvil79 |
last post by:
I'm implementig a java web application using MySQL as database.
The main function of the application is basically to redistribuite
documents. Those documents (PDF, DOC with an average size around 2Mb)
are stored in BLOB column.
The amount of documents for the first year should not exceed 5/6 Giga,
but I cannot make prevision for the next years.
Those documents are mainly just accessed (update and delete are not so
|
by: Lyn |
last post by:
I am trying to copy selected fields from one table to another, by reading
the source table record into a recordset (ADO) and then copying the relevant
fields to an SQL statement "INSERT INTO...". The numeric and text fields
copy without a problem, but it all falls in a heap when I try to copy a
picture object field (data type OLE Object in both tables). I seem to be
missing something ???
Reduced to its simplest form, this is the code...
|
by: m.k.ball |
last post by:
Thanks Rich - that's great. Before I found this group, I thought I had
a reasonable understanding of SQL (well, MySQL's implementation of it,
at least) but the truth is there are great chunks that I have no
knowledge of. I've read three or four books about MySQL and PHP all of
which gave (in retrospect) very basic examples of the use of SQL, and
focussed on features such as MySQL's date and time handling functions
that are well covered in...
| |
by: Ted |
last post by:
1) In several tables, in my MySQL version, I created columns using
something like the following:
`ab_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP,
This allowed me to ensure that when a record is either added or edited,
the value in the field is set to the current date and time. I.E.,
ab_timestamp is given the current date and time when a record is
created, and then it is updated to the date and...
|
by: onnodb |
last post by:
Hi all,
While working on an Access UI to a MySQL database (which should be a
reasonable, low-cost, flexible interface to the DB, better than
web-based, much less costly than a full-fledged .NET app or so.... is
it?), I tried measuring the bandwith consumed by the
Access/MyODBC/MySQL link, which came out to be, er, quite high.
I fancied it would be interesting to look at the queries Access throws
at MySQL through the ODBC link, so I...
|
by: Vinciz |
last post by:
hi guys... im new in java and i would love to learn some of these...
basically i got a sample code to retrieve the blob from the mysql.
however, i dont really know what to do with these retrieved byte/binary data as i got no idea on how to save them in our pc. For this situation, what i need to do is give the byte/binary data an extension (retrieved from another field in the table) in order to revert back to the original data i had in the...
|
by: bill |
last post by:
I am about to start on a module that will accept a location from
a user, use Google geolocation services to get the lat/lon and
then compute the distance from the site visitor to about 100
kennels (could grow to 1000 eventually).
Once I have the distance I need to sort the kennels by distance
and present those within 500 miles.
Approach 1: read the kennel lat/lon from the mysql kennel record
compute the distance
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |