On Fri, Jun 03, 2005 at 03:50:09PM -0400, Lloyd Kvam wrote:
> The code to update the database should look something like:
> the_cursor.execute( sql_cmd, data)
>
In PyGreSQL/pgdb it's cursor.execute(query[, params]) but it means
more or less the same thing because pgdb's paramstyle (I knew from the
>data = {}
>data['ids_to_process'] = ['1','2','3','5','7','11']
>
>query = '''
>UPDATE my_table
> SET state = 'processed'
> WHERE id IN ARRAY%(ids_to_process)s
>'''
>db.execute(query, data)
>
Sorry. It should look like ...
query = '''
UPDATE my_table
SET state = 'processed
The code to update the database should look something like:
the_cursor.execute( sql_cmd, data)
I am not using postgresql so I do not know the place-holder mark for
your module. You can get that from the module documentation.
So sql_cmd could be something like
"UPDATE my_table SET
On Fri, 3 Jun 2005, Gabriel Farrell wrote:
> def sqlNice(valueList):
> count = 1
> y = '('
> for x in valueList:
> x = x.replace("'", "''")
> y = y + "'" + x + "'"
> if count < len(valueList):
> y = y + ', '
> count = count + 1
> y = y
On Thu, Jun 02, 2005 at 10:41:20PM +0100, Alan G wrote:
> Why not convert the list to a tuple before applying str():
>
> str(tuple(ids_to_process))
I'm just getting started with Python and PostgreSQL but I found that
str(tuple(valueList)) wouldn't work for me because I had a few values
with apost
Hmm, I dunno ADOpy but assume it somehow miraculously turns your dataset into a dictionary of some sort? How it guesses which order the
SELECT will return the fields is a mystery to me, but maybe it hasknowledge of the Postgres hashing function or somesuch.
Yeah. I used to do it by hand by look
Rumor has it that Alan G may have mentioned these words:
>Hmm, I dunno ADOpy but assume it somehow miraculously turns your data
>set into a dictionary of some sort?
I dunno ADOpy, but the pg module for PostgreSQL can return a list of
dictionaries from a query.
>>> import pg
>>> pg.set_defuser
> > SELECT * does not normally guarantee anything about the order of
fields
> > returned, so if the table gets an extra field added you might find
the order
>
> I'm using SELECT * specifically for this reason! I have the query
and
> customer specific data layouts stored in a database and am using
A
On 6/2/05, Alan G <[EMAIL PROTECTED]> wrote:
Its a really bad idea to use SELECT * FROM in production code.There are two main reasons:1)
If the database structure changes your code is likely to break since
SELECT * does not normally guarantee anything about the order of fields
returned, so if the t
>data = {}
>data['start_date'] = '2005-6-2'
>data['last_name'] = 'Johnson'
>
>query = '''
>SELECT *
> FROM my_table
> WHERE date >= '%(start_date)s'
> AND last_name = '%(last_name)s'
>''' % data
>results = my_database.Execute(query)
First up. This is a "bad idea".
It may be ok
> I am building a query to hit a Postgres (8.0.1) database
> from Python (4.2.1) on Linux. Here's how I've been doing
> it for the past year or so:
> ...
> query = '''
> SELECT *
> FROM my_table
>
Its a really bad idea to use SELECT * FROM in production code.
There are two main reasons:
1) I
At 06:48 AM 6/2/2005, Greg Lindstrom wrote:
Hello-
I am building a query to hit a Postgres (8.0.1) database from Python
(4.2.1) on Linux. Here's how I've been doing it for the past year
or so:
data = "">
data['start_date'] = '2005-6-2'
data['last_name'] = 'Johnson'
query = '''
SELECT *
12 matches
Mail list logo