JuliaDatabases / DBAPI.jl

A new database interface proposal
Other
12 stars 12 forks source link

Add methods for prepared statements and metadata. #7

Closed nkottary closed 8 years ago

nkottary commented 8 years ago

Added methods prepare and bind to support prepared statements. This helps improve performance when the same query has to be executed repeatedly with different parameters. The query can be prepared once using prepare and every time it is used new parameters can be bound to it using bind.

Also added a type Metadata and a method metadata to retrieve metadata of the result set after execute!.

iamed2 commented 8 years ago

The intent is to have a query type which represents a query to be executed with many parameters, and those parameters are passed as a field in the query type.

One of the big mistakes of DBI.jl was having prepared statements in the interface. Prepared statement semantics differ wildly between database systems and the idea of a "prepared statement" isn't a consistent one. I am strongly against including any functions dealing with prepared statements in DBAPI.jl.

As for metadata: the better option, which I am exploring in PostgreSQL.jl, is to have a result set type. This can be both returned from execute, and stored in the cursor (the result of the last query run on the cursor). Any metadata can be encapsulated within or made available through that type.