如何用Dart连接mysql数据库? [英] How to connect mysql Database with Dart?

查看:682
本文介绍了如何用Dart连接mysql数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何使用Dart连接到mysql数据库吗?我已经阅读和搜索了几天,但找不到任何合适的答案.我只是学习网络编程.谢谢!

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!

推荐答案

您可以使用 SQLJocky 连接到MySQL.添加

You can use SQLJocky to connect to MySQL. Add

dependencies:
  sqljocky: 0.0.4

运行 pub安装到您的 pubspec.yaml .现在您可以像这样连接到MySQL

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);
    }
  });
});

这篇关于如何用Dart连接mysql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆