How to connect the mysql database with Dart?

advertisements

Does anyone can tell me how to connect to mysql database with Dart? I've been reading and searching for days but can't find any suitable answers. I just learning web programming. Thank you!


You can use SQLJocky to connect to MySQL. Add

dependencies:
  sqljocky: 0.0.4

to your pubspec.yaml an run pub install. Now you can connect to MySQL like this

var cnx = new Connection();
cnx.connect(username, password, dbName, port, hostname).then((nothing) {
    // Do something with the connection
    cnx.query("show tables").then((Results results) {
    print("tables");
    for (List row in results) {
      print(row);
    }
  });
});