File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -1348,7 +1348,28 @@ impl Connection {
1348
1348
1349
1349
/// Send a simple, non-prepared query
1350
1350
///
1351
- /// TODO docs. Should this replace the batch_execute API?
1351
+ /// Executes a query without making a prepared statement. All result columns
1352
+ /// are returned in a UTF-8 text format rather than compact binary
1353
+ /// representations. This can be useful when communicating with services
1354
+ /// like _pgbouncer_ which speak "basic" postgres but don't support prepared
1355
+ /// statements.
1356
+ ///
1357
+ /// Because rust-postgres' query parameter substitution relies on prepared
1358
+ /// statements, it's not possible to pass a separate parameters list with
1359
+ /// this API.
1360
+ ///
1361
+ /// In general, the `query` API should be prefered whenever possible.
1362
+ ///
1363
+ /// # Example
1364
+ ///
1365
+ /// ```rust,no_run
1366
+ /// # use postgres::{Connection, TlsMode};
1367
+ /// # let conn = Connection::connect("", TlsMode::None).unwrap();
1368
+ /// for row in &conn.simple_query("SELECT foo FROM bar WHERE baz = 'quux'").unwrap() {
1369
+ /// let foo: String = row.get("foo");
1370
+ /// println!("foo: {}", foo);
1371
+ /// }
1372
+ /// ```
1352
1373
pub fn simple_query ( & self , query : & str ) -> Result < Vec < TextRows > > {
1353
1374
self . 0 . borrow_mut ( ) . simple_query_ ( query)
1354
1375
}
You can’t perform that action at this time.
0 commit comments