[sqlalchemy] Storing and Retrieving BLOB in SqlAlchemy

2013-02-26 Thread dalia
Hi, My intention is - to store .xls, .doc and .pdf files (with images in them) to store in a Oracle database and retrieve them. I'm using SQLAlchemy declarative code. The problem is, the data gets stored in the database but when I try to fetch the data back, it comes out as 0KB. I'm explaining

Re: [sqlalchemy] Storing and Retrieving BLOB in SqlAlchemy

2013-02-26 Thread Mauricio de Abreu Antunes
Well, I think you need to import BLOB from dialects like: from sqlalchemy.dialects.oracle import BLOB in your Model you can describe the field type following it: MyBLOBColumn = Column(BLOB) Actually, IMHO i don't think saving large contents (binary from binary files) as pure text in the

Re: [sqlalchemy] Storing and Retrieving BLOB in SqlAlchemy

2013-02-26 Thread dalia
Hi Mauricio, Thanks for the reply. But importing BLOB specifically did not solve the problem. It is the same. In the INSERT statement, it looks like it is storing the file in Binary, but then when I query the database, it just shows (BLOB) and not the data. My requirement is to store .xls,

Re: [sqlalchemy] Storing and Retrieving BLOB in SqlAlchemy

2013-02-26 Thread Mauricio de Abreu Antunes
Well, I would store the pshysical file in a system folder. After this I would save the path to the file in a table. Then you could manage your files via sqlalchemy, listing all files and working with them properly. 2013/2/26 dalia dalia@gmail.com Hi Mauricio, Thanks for the reply. But

Re: [sqlalchemy] Storing and Retrieving BLOB in SqlAlchemy

2013-02-26 Thread Werner
Hi Dalia, On 26/02/2013 17:15, dalia wrote: self._get_file(content) ### This is a function which generates the file (.xls / .doc / .pdf) in the content What are you getting back from _get_file? Is it in a format you can store in the db column and then restore it to a file? Doing a

Re: [sqlalchemy] Storing and Retrieving BLOB in SqlAlchemy

2013-02-26 Thread Michael Bayer
On Feb 26, 2013, at 9:44 AM, dalia dalia@gmail.com wrote: Retrieving from database - now I want the file to be downloaded as an excel (.xls) file def _get_report(self): tbl = model.ReportFiles file = meta.Session.query(tbl).get(id=1) contentstr = file.report_file

Re: [sqlalchemy] connecting to redshift

2013-02-26 Thread Randy Shults
Any reason this wouldnt work? (Disclaimer: Redshift is my first intro to postgre -- and I've never had a reason to use sqlalchemy before -- so this could be a really dumb question). Seems to connect and query fine...if this doesn't work -- please let me know why: def get_conn(): conn =

[sqlalchemy] Joining Algorithmically

2013-02-26 Thread Arkilic, Arman
Hi, I have four tables that I would like to join algorithmically. Element with element_prop, elementprop with element_typeprop in one direction and element with element_type in the other. I would like to do this in one line as I am concerned about the number queries must be minimal given I am

Re: [sqlalchemy] connecting to redshift

2013-02-26 Thread Michael Bayer
On Feb 26, 2013, at 4:58 PM, Randy Shults randy.c.shu...@gmail.com wrote: Any reason this wouldnt work? (Disclaimer: Redshift is my first intro to postgre -- and I've never had a reason to use sqlalchemy before -- so this could be a really dumb question). Seems to connect and query

Re: [sqlalchemy] Joining Algorithmically

2013-02-26 Thread Michael Bayer
On Feb 26, 2013, at 5:15 PM, Arkilic, Arman arki...@bnl.gov wrote: Hi, I have four tables that I would like to join algorithmically. Element with element_prop, elementprop with element_typeprop in one direction and element with element_type in the other. I would like to do this in one line

Re: [sqlalchemy] connecting to redshift

2013-02-26 Thread Randy Shults
Awesome thanks. Yeah -- I can confirm no issues at all integrating with Redshift. I've created/deleted tables, copied in 5GB of data from s3, and executed several queries against it all through sqlalchemy with the psycopg2 dialect. (I've been working in raw SQL for 7 years, so I'm only using