Opened 10 months ago

Closed 9 months ago

#76 closed enhancement (fixed)

Support and document usage of prepared statements

Reported by: cito Owned by:
Priority: major Milestone: 5.1
Component: Classic and DB API Version: 5.0
Keywords: prepared Cc:

Description

The C module needs to be extended to support the PQprepare, PQexecPrepared and PQdescribePrepared functions.

The pg and pgdb interfaces need to make use of this.

See also mailing list 2018-12-09 and #16.

Change History (4)

comment:1 Changed 10 months ago by cito

Note that executing prepared statements already works with this workaround:

db.query('prepare c AS INSERT INTO tweets VALUES($1,$2,$3)')
db.query_formatted('execute c(%s,%s,%s)', [45, 'trump', 'so sad'], inline=True)

But it doesn't work with inline=False (or db.query for that matter).

It would be nice to have special prepare(), exec_prepared(), describe_prepared() and delete_prepared() methods for working with prepared statements, which use the corresponding C functions (delete_prepared() would use deallocate, it doesn't have a corresponding C function).

Last edited 10 months ago by cito (previous) (diff)

comment:2 Changed 10 months ago by cito

See also solution proposed by Justin on the mailing list 2018-12-14 and 2018-12-22.

Last edited 10 months ago by cito (previous) (diff)

comment:3 Changed 9 months ago by cito

This has now been implemented between r953 and r961.

The new methods are prepare(), query_prepared(), describe_prepared() and delete_prepared().

comment:4 Changed 9 months ago by cito

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.