Bob Fnord wrote: > I want a portable data file (can be moved around the filesystem > or copied to another machine and used), so I don't want to use > mysql or postgres. I guess the "sqlite" approach would work, but > I think it would be difficult to turn the tuples of strings and > lists of strings and numbers into database table lines.
This is as hairy as it's ever got for me (untested): def inserter (db, table_name, names, values): query = 'INSERT INTO %s (%s) VALUES (%s)' % (table_name, ','.join (names), ','.join (['?'] * len (names))) cur = db.cursor() cur.execute (query, values) cur.close() #... for v in all_value_triples: inserter (db, 'some_table', ['f1', 'f2', 'f3'], v) (or even write a bulk_inserter that took all_value_triples as an argument and moved the `for v in ...` inside the function.) > Would a database in a file have any advantages over a file made > by marshal or shelve? Depends. An sqlite3 database file is usable by programs not written in Python. > I'm more worried about the fact that a python program in user > space can bring down the computer! Never been a problem in the programs I've written. Mel. -- http://mail.python.org/mailman/listinfo/python-list