0

Trying to query mysql database with sqljocky. This query works fine in phpmyadmin and return 5 rows with fine data. In Dart i got exception:

Class '_ResultsImpl' has no instance method 'forEach'.

I made breakpoint in query callback. Result object public filds are empty: enter image description here

Ping function works well, so connection to base is established. enter image description here

Even if i query simple "show tables" query, it returns to me empty Results instance with no data.

Query code below:

var pool = new ConnectionPool(
        host: '127.0.0.1', port: 8889, 
        user: 'root', password: 'root', 
        db: 'lulzvideo', max: 5);


pool.query('select id, title from users')
    .then((results) {   
      results.forEach((row) {
        print('Name: ${row[0]}, email: ${row[1]}');
      });
    });
kolombet
  • 87
  • 1
  • 1
  • 7
  • Your code worked for me, but if I put that code (slightly modified for my table) in a main it will not complete. So if I add: *.then((_) => pool.close())* before the last semicolon it works fine. Are you sure about the parameters to the connection (i.e. are you pointing to the db with the data you expect)? I am using sqljocky-0.11.0 – user1338952 Oct 15 '14 at 15:32

1 Answers1

0
result.listen((row) {
  // Import into object
  object.Import(row);

sqljocky querying database synchronously

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567