473,799 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading BLOB

How can I read a binary value from a blob via ODBC (Microsoft VFP
driver-win32all)? The value seems to be truncated at the first '\0'

TIA
Jul 18 '05 #1
3 6444
Johan Vervoort wrote:

How can I read a binary value from a blob via ODBC (Microsoft VFP
driver-win32all)? The value seems to be truncated at the first '\0'


Maybe posting a very small snippet of code which reproduces the
problem would help get you responses. I can't help, as I don't
know what VFP driver-win32all is, but if there was example code I
might be able to see the problem anyway, and others more expert in
this area would likely see the problem right away.

-Peter
Jul 18 '05 #2
This is the sample code: It should dump all the certificates to the
certs directory...
What I suspect is that python thinks that the certif field is a STRING
and it's truncated when the first '\0' occurs...
(The data is stored completely in the database as an equivalent
C-program works fine...)

Sample output:
reload (Test)
[('csernum', 'STRING', 80, 80, 0, 0, 0), ('certif', 'STRING', 0,
2147483647, 0, 0, 0)]
csernum
certif
import dbi, odbc

def ReadCmail():
result = { 'Result' : 'OK' }

# Microsoft Visual FoxPro ODBC DNS
# Database type: Free table directory
dbc = odbc.odbc('CEC' )
cursor = dbc.cursor()
query = "SELECT CSERNUM,CERTIF FROM C_MAIL"
cursor.execute( query)

row = cursor.fetchone ()
for row in iter(cursor.fet chone, None):
# Dump certif to file
FileName="C:\\C ERTS\\%s.crt" % row[0]
CertFile = open(FileName, "wb")
CertFile.write( row[1])
CertFile.close( )

print cursor.descript ion
for tup in cursor.descript ion:
print tup[0]

cursor.close()
dbc.close()
return result

ReadCmail()

On Wed, 21 Jan 2004 09:20:32 -0500, Peter Hansen <pe***@engcorp. com>
wrote:
Johan Vervoort wrote:

How can I read a binary value from a blob via ODBC (Microsoft VFP
driver-win32all)? The value seems to be truncated at the first '\0'


Maybe posting a very small snippet of code which reproduces the
problem would help get you responses. I can't help, as I don't
know what VFP driver-win32all is, but if there was example code I
might be able to see the problem anyway, and others more expert in
this area would likely see the problem right away.

-Peter


Jul 18 '05 #3
Jo************@ utimaco.be wrote:

This is the sample code: It should dump all the certificates to the
certs directory...
What I suspect is that python thinks that the certif field is a STRING
and it's truncated when the first '\0' occurs...
(The data is stored completely in the database as an equivalent
C-program works fine...)


Python itself does not care about '\0' in a string, and will happily
handle strings with any kind of binary data.

At the least, then you need to look lower, perhaps at the ODBC wrapper
code itself, perhaps at the database schema or something. Are there
multiple types of string that can be stored in the database, and you've
picked one that is effectively null-terminated? Or, wait a minute, your
subject line is "reading BLOB", yet you are dealing with strings in
some way, given this:
reload (Test)

[('csernum', 'STRING', 80, 80, 0, 0, 0), ('certif', 'STRING', 0,
2147483647, 0, 0, 0)]

Surely that is the cause of the problem, at least indirectly? Isn't
there some kind of BLOB data type instead?

-Peter
Jul 18 '05 #4

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

Similar topics

7
7101
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and disadvantages of using a MySQL blob field rather than reading the images directly from the file? How does one insert an image into a blob field? Can it be done dynamically? Thank you John
1
1799
by: Ramesh | last post by:
How to read a BLOB from oracle 8i using OleDb
5
2081
by: ssp | last post by:
Dear all, I'm dealing with a very tricky problem and can't seem to find the answer with google. the problem is: i want to store huge data (binaries) inside a mysql databases blob - to later store those data to a file somewhere else (from where i can connect the database). problem comes into play, when I try to output a "progress" of the reading of this data (kind of "xx bytes of XXX bytes already transmitted").
1
6532
by: sid_mulpuru | last post by:
I am trying to read data from a DB2 Blob Data type Field (using wsad 5.1.0) using getBlob() which when executed gives an SQL Exception 2005-01-07 15:48:40,506 ERROR - Error in servlet:xxxxx.jsp initiateDownloadFri Jan 07 15:48:39 CST 2005com.ibm.db2.jcc.a.SqlException: 1 (in debug mode exception called at rs =
0
1193
by: arbidol | last post by:
i want to read and write blob data from access2000 using dao3.6, but i found it is slower than ado. As i know, reading access with dao is the best way, what happens? the mdb file i want to read contains a table with 150000 rows and a blob field, i wish to fetch all rows in 3-4 secondes. What can i do, improving the speed of i/o read and write or improving the number of page buffer pool ?
1
3303
by: Roberto Castro | last post by:
I have some problems with the way I am showing the BLOB fields in the Image web controls. It does work on my localhost though sometimes I need to hit Refresh for the images to load properly. However, when I try to access the same page from another machine or when I test the code on a remote server the images just wouldn't show. The page I am talking about has 3 Image web controls. In the CodeBehind I am loading these controls by using an...
0
1471
by: MdAZ | last post by:
We need to read and store BLOB's as storage object in MS Access databases via OLE DB. We have used several methods but no one was succesfull. If one tries the code supplied under the article "Getting BLOB Data with Storage Object" of the MSDN library, IAccessor::CreateAccessor returns an error code and sets DBBINDSTATUS to DBBINDSTATUS_NOINTERFACE for the column that contains the BLOB even though DBCOLUMNFLAGS_ISLONG is set for this...
1
2114
by: Ken | last post by:
Hello, I'm trying to read a Blob from Oracle and then write it to an audio file(.AU). I'm using Visual Studio.Net 2003 (VB). I can't seem to get my code to work. Will someone take a look at it and tell me what am I doing wrong. Any help would be appreciated. Thanks Dim Conn As OracleConnection = New OracleConnection("data source=XXXX;user id=XXXXX;password=XXXXX")
2
3754
by: Chucker | last post by:
Hi Community, I think I can store Binary Data in SQL Server but when I try to retrieve it, I always only get one byte. I think I stored my Binary Data in SQL Server in a Colum of Type Image. At least when I execute the following code, I get some significant network traffic. When I check the database with query analyzer, I see 4 Hex Chars in the image colum. Like 0xe0 etc.
0
9541
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,...
1
10225
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
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...
0
9072
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, 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...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
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
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.