[Chicago] 2 unique keys in a python dict?
Massimo Di Pierro
mdipierro at cs.depaul.edu
Thu Oct 9 20:26:51 CEST 2008
I do not know what tps files are but in web2py you can connect to
multiple databases at once
db=SQLDB('sqlite://....')
db1=SQLDB('mssql://....')
db2=SQLDB('mysql://....')
process them
for row in db1(...).select():
db.mytable.insert(field=row.other_field,...)
for row in db2(...).select():
db.mytable.insert(field=row.other_field,...)
and you can serialize any select query back in CSV using str(..)
open('output.csv','w').write(str(db(....).select()))
If this is useful, feel free to email me personally with more details
and I am happy to answer any question.
Massimo
On Oct 9, 2008, at 12:21 PM, Lukasz Szybalski wrote:
> On Thu, Oct 9, 2008 at 11:53 AM, John Hunter <jdh2358 at gmail.com>
> wrote:
>> On Thu, Oct 9, 2008 at 11:19 AM, Massimo Di Pierro
>> <mdipierro at cs.depaul.edu> wrote:
>>
>>>>>> rows
>>>>>> =
>>>>>> db
>>>>>> ().select
>>>>>> (db
>>>>>> .mytable
>>>>>> .ttid
>>>>>> ,db
>>>>>> .mytable
>>>>>> .paid.sum(),orderby=db.mytable.ttid,groupby=db.mytable.ttid)
>>>>>> for row in rows:
>>> ... print 'transaction',row.ttid,'total
>>> amount',row[db.mytable.paid.sum()]
>>
>> Or use matplotlib's support for CSV files via numpy record arrays
>>
>> import matplotlib.mlab as mlab
>> r = mlab.csv2rec('myfile.csv')
>> print r.paid.sum()
>>
>> csv2rec does type inference from the data in the file, and numpy
>> arrays support all the standard math and stat operations (mean, std,
>> logical masks, etc...)
>
> This is a combination of sqlserver2000, clarion tps files via odbc,
> mysql server, all with different fields structure that at the end need
> to show up on the excel.
>
> Wish there was an easier way of merging these sources into some csv
> based reporting tool, getting the proper totals, and output final csv
> file in under 2 weeks.
>
> Lucas
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
More information about the Chicago
mailing list