[Chicago] 2 unique keys in a python dict?
szybalski at gmail.com
Thu Oct 9 21:24:41 CEST 2008
On Thu, Oct 9, 2008 at 1:45 PM, Massimo Di Pierro
<mdipierro at cs.depaul.edu> wrote:
> In a more concise terms. Say I have a table "mytable" with a column a
> (double) and b (string) and want to read data in from a csv file, group by
> b, add all a's for the same b and write the result back in CSV. In web2py I
> do (complete code):
> How do I do it in Django?
> On Oct 9, 2008, at 1:30 PM, James Snyder wrote:
> Someone has written a script that will do that:
> You'd first have to create your model and do a syncdb to set up the tables,
> but that's easy
> I don't have a full code example, but ORDER BY is not hard with the Django
> ORM. Look for order_by in the query
> docs: http://docs.djangoproject.com/en/dev/topics/db/queries/
> Also, it may not give you nice object mapping goodness, but using the
> sqlite3 and csv modules aren't too bad. Note that going that route,
> however, will require writing the SQL queries yourself :-)
> On Oct 9, 2008, at 1:05 PM, Massimo Di Pierro wrote:
> Can the Django ORM import CSV files and/or generate ORDER BY queries without
> additional code snippets?
> If so, could you post example?
I use sqlalchemy to read from sqlserver2000, and mysql.
I use csv module with a DictReader so I get a dictonary. Based on that
you I loop csv records and use sqlalchemy to get more information. If
you want you can create any table you want...which supports sqlite,
memory , mysql, m$sql, postgre, oracle,... but for this purpose its a
1 in 5 years report.
order by, group by etc is supported, as well as session, transaction,
One of the sql query looks like:
Can't get easier than that.....put this in a loop, and for any record
you can get the information you want from database....
sqlalchemy and cvs module works for me.
More information about the Chicago