Re: [sqlalchemy] Dabo ReportDesigner/Writer

2013-06-12 Thread Werner

Hi,

On 04/06/2013 08:26, Werner wrote:

Hi,

I am looking at Dabo's ReportDesigner/Writer to do reporting (looked 
at others like PythonReports and Geraldo) but both have problems with 
large text blobs.


It wants the data as:

Dabo's reportwriter wants dataset-like structures, which is a sequence 
(list, tuple) of mappings (dict), where each key in the mapping is a 
field name, and each item in the outer sequence is a record.


I managed to figure this out:

result = session.query(db.Cellarbook.avgpurchaseprice,
   db.Drinkinfo.name)
result = result.join(db.Drinkinfo)

print result

for row in result.all():
print row.__dict__['name']

This won't work as if there are two columns with name, then only the 
last one can be accessed this way.


E.g.:
result = session.query(db.Cellarbook.id,
   db.Drinkinfo.name,
   db.Container_LV.name)

for row in result.all():
print row.__dict__['name']

Will give me the column value of Container_LV.name, I tried using 
with_labels but it doesn't seem to affect the __dict__ keys.


When I look at:
row.keys()
['id', 'name', 'name']

This is with SA 0.8.1.

Anyone has some tips on how I could make Dabo ReportWriter happy.

Werner

--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] Dabo ReportDesigner/Writer

2013-06-12 Thread Michael Bayer

On Jun 12, 2013, at 7:17 AM, Werner werner.bru...@sfr.fr wrote:

 Hi,
 
 On 04/06/2013 08:26, Werner wrote:
 Hi,
 
 I am looking at Dabo's ReportDesigner/Writer to do reporting (looked at 
 others like PythonReports and Geraldo) but both have problems with large 
 text blobs.
 
 It wants the data as:
 
 Dabo's reportwriter wants dataset-like structures, which is a sequence 
 (list, tuple) of mappings (dict), where each key in the mapping is a field 
 name, and each item in the outer sequence is a record.
 
 I managed to figure this out:
 
 result = session.query(db.Cellarbook.avgpurchaseprice,
   db.Drinkinfo.name)
 result = result.join(db.Drinkinfo)
 
 print result
 
 for row in result.all():
print row.__dict__['name']
 
 This won't work as if there are two columns with name, then only the last one 
 can be accessed this way.
 
 E.g.:
 result = session.query(db.Cellarbook.id,
   db.Drinkinfo.name,
   db.Container_LV.name)
 
 for row in result.all():
print row.__dict__['name']
 
 Will give me the column value of Container_LV.name, I tried using 
 with_labels but it doesn't seem to affect the __dict__ keys.
 
 When I look at:
 row.keys()
 ['id', 'name', 'name']
 
 This is with SA 0.8.1.


in that situation you need individual labels:

s.query(A.id, B.name, C.name.label(c_name), ...)


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] Dabo ReportDesigner/Writer

2013-06-12 Thread Werner

Hi Michael,

On 12/06/2013 17:40, Michael Bayer wrote:
...

Will give me the column value of Container_LV.name, I tried using 
with_labels but it doesn't seem to affect the __dict__ keys.

When I look at:
row.keys()
['id', 'name', 'name']

This is with SA 0.8.1.


in that situation you need individual labels:

s.query(A.id, B.name, C.name.label(c_name), ...)


Great, thanks for the quick reply
Werner

--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sqlalchemy] Dabo ReportDesigner/Writer

2013-06-04 Thread Werner

Hi,

I am looking at Dabo's ReportDesigner/Writer to do reporting (looked at 
others like PythonReports and Geraldo) but both have problems with large 
text blobs.


It wants the data as:

Dabo's reportwriter wants dataset-like structures, which is a sequence 
(list, tuple) of mappings (dict), where each key in the mapping is a 
field name, and each item in the outer sequence is a record.


I managed to figure this out:

result = session.query(db.Cellarbook.avgpurchaseprice,
   db.Drinkinfo.name)
result = result.join(db.Drinkinfo)

print result

for row in result.all():
print row.__dict__['name']


Is using row.__dict__ the correct way or are there other ways?

Best regards
Werner

--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.