query abstract method

Stream<Row> query(
  1. String sql, [
  2. dynamic values
])

Queue a sql query to be run, returning a Stream of Rows.

If another query is already in progress, then the query will be queued and executed once the preceding query is complete.

The results can be fetched from the Rows by column name, or by index.

Generally it is best to call Stream.toList on the stream and wait for all of the rows to be received.

For example:

conn.query("select 'pear', 'apple' as a").toList().then((rows) {
   print(row[0]);
   print(row.a);
});

Values can be substitued into the sql query. If a string contains quotes or other special characters these will be escaped.

For example:

var a = 'bar';
var b = 42;

conn.query("insert into foo_table values (@a, @b);", {'a': a, 'b': b})
  .then(...);

Or:

conn.query("insert into foo_table values (@0, @1);", [a, b])
   .then(...);

If you need to use an '@' character in your query then you will need to escape it as '@@'. If no values are provided, then there is no need to escape '@' characters.

Implementation

Stream<Row> query(String sql, [values]);