首页 新闻 会员 周边 捐助

Flutter里面Mysql1插件连接没有问题,为何没有数据返回呢?

0
悬赏园豆:20 [待解决问题]

我使用Myslq1作为我的Mysql数据库的连接插件,但是连接看起来没有问题,为何没有数据返回呢?请高手帮忙看一下,谢谢。

import 'package:mysql1/mysql1.dart' as mysql;

Future Database() async {
var settings = mysql.ConnectionSettings(
host: '108...',
port: 3306,
user: 'root',
password: '
*****',
useSSL: false,
useCompression: false,
// maxPacketSize: 10000000,
//characterSet: utf8,
timeout: const Duration(seconds: 5000),
db: 'testdb');
var conn = await mysql.MySqlConnection.connect(settings);

print(conn.toString());
var result = await conn.query("SELECT * FROM users LIMIT 100;");
//await conn.close();
if (result.isEmpty) {
print('No data');
} else {
print(result.toString());
}
await conn.close();
}

运行结果:

[Running] dart "d:\Project\Flutter\e_shop\lib\service\service_method.dart"
lib/service/service_method.dart: Warning: Interpreting this as package URI, 'package:e_shop/service/service_method.dart'.
Instance of 'MySqlConnection'
No data

[Done] exited with code=0 in 2.066 seconds

商君治国安邦之张莽的主页 商君治国安邦之张莽 | 初学一级 | 园豆:137
提问于:2022-01-04 22:30
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册