Re: Dictionary
Tim Roberts <[email protected]> Tue, 20 Apr 2010 13:52:03 -0700
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Organization | Providenza & Boekelheide, Inc. |
| Message-ID | <[email protected]> |
Antonio Prado wrote: > I'm working with Python and PostgreSQL. > > To assign values to the dictionary returned by psycopg2, I'm doing the > following: > > register[register._index['key']] = new_value > > This correct or should I do otherwise? > Well, I guess it depends on what it is you are trying to do. If you are trying to modify the database, this is not correct. The dictionary you get back from a query is a local copy -- a snapshot of the query results. The only way to make a change is to create an UPDATE query and call cursor.execute to send it to the database server. Why don't you post more of your code, along with a short description of what you're trying to do, and we can tell you how to do that? -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc.