Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: DB

Adding and retrieving files from PostgreSQL with ZPsycopgDA

 

 

Zope db RSS feed   Index | Next | Previous | View Threaded


krokodylek at tenbit

Jun 30, 2006, 12:43 PM

Post #1 of 2 (1268 views)
Permalink
Adding and retrieving files from PostgreSQL with ZPsycopgDA

Hi :)

I wanted to ask if there's any way to send a file to PostgreSQL database?

The file I have is taken from REQUEST, from multipart form. I need to
send it to the database and later retrieve it when needed. I guess I
should use the bytea field and an Z SQL Methods.

But how can I send the file? - dtml-sqlvar can only be of "string",
"int", "float" or "nb" type. How should the method's template look like?

And how do I get the bytes back and re-create the file object?

I guess what I need to know is how you send binary data with ZPsycopgDA...

I really need help with this :-( Any suggestions are really, really
welcome. If there's any more information needed please let me know.

Please excuse my poor English :)

Best regards,
Maciej Zieba
_______________________________________________
Zope-DB mailing list
Zope-DB [at] zope
http://mail.zope.org/mailman/listinfo/zope-db


charlie at egenix

Jul 1, 2006, 4:26 AM

Post #2 of 2 (1173 views)
Permalink
Re: Adding and retrieving files from PostgreSQL with ZPsycopgDA [In reply to]

Maciej Zięba wrote:
> Hi :)
>
> I wanted to ask if there's any way to send a file to PostgreSQL database?
>
> The file I have is taken from REQUEST, from multipart form. I need to
> send it to the database and later retrieve it when needed. I guess I
> should use the bytea field and an Z SQL Methods.
>
> But how can I send the file? - dtml-sqlvar can only be of "string",
> "int", "float" or "nb" type. How should the method's template look like?

Use string because no type-checking is involved.

> And how do I get the bytes back and re-create the file object?

This crops up occasionally on the list so search the archives for examples.

> I guess what I need to know is how you send binary data with ZPsycopgDA...

Because of the way Zope talks to databases you might run into the
problem that the generated SQL is too big in which case you might want
to use an ExternalMethod to handle the call. I don't think that
ZPscopgDA allows you to call .execute on connections so if this is
necessary and you want to avoid writing a lot of code, you might want to
try the mxODBCZopeDA which makes writing this kind of code a doddle.
Again searcg the archives for some examples.

> I really need help with this :-( Any suggestions are really, really
> welcome. If there's any more information needed please let me know.

Charlie

_______________________________________________
Zope-DB mailing list
Zope-DB [at] zope
http://mail.zope.org/mailman/listinfo/zope-db

Zope db RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.