How do I execute the following using psycopg2?
This does not really work:
cursor.exetec ("Enter in file (name, quantity) value (% s,% S) "," Foo "," (select ID from volume where quantity .name = 'bar') ")
Select ID from volume where volume.name = 'bar '
can be replaced by a call for stored procedure:
lookup_vol_id (' bar ')
thanks
< / Div>
You use INSERT
as INSERT ... SELECT Do Sector, eg:
Enter the name of the file (name, quantity) SELECT 'foo', (select ID from the volume where volume.name = 'bar');
Or if names
and columns
are only columns in that table, in that order, you can completely exclude column names Skip:
SELECT 'foo' file INSERT, (choose the ID from the volume where volume.name = 'bar');
Either the SQL string can be passed in the cursor.execute
(without semicolons).
On the one hand, it seems that the name of the quantity
column should be changed to volume_id
, as it id
Columns Amount
is from the table.
No comments:
Post a Comment