mysql1_dart icon indicating copy to clipboard operation
mysql1_dart copied to clipboard

MySQL1 not closing connection

Open timothyao opened this issue 3 years ago • 2 comments

MySQL1 not closing connection in a Dart console application running on Windows 10, in debug mode. Find an example of the code structure below:

final conn = await MySqlConnection.connect(_settings);
Results results;

      if (branches.isNotEmpty) {
        for (var branch in branches) {
                await conn.query('INSERT INTO branches (id, name) VALUES (?,?)', [branch.id, branch.name]);
          }
        }

await conn.close();

Thanks in advance.

timothyao avatar Sep 12 '22 06:09 timothyao

You dont need an Await Func. Try it only conn.close();

berkayhh avatar Apr 30 '23 10:04 berkayhh

Hi @berkayhh,

Thanks for the suggestion, but I am curious to why you think removing the await function would work. From my limited knowledge, an await will wait till the connection is closed before proceeding with the next line of code. Or am I missing something?

Best Regards

timothyao avatar May 02 '23 21:05 timothyao