adamlofts / mysql1_dart

MySQL driver for Dart
Other
134 stars 45 forks source link

MySQL1 not closing connection #140

Open timothyao opened 2 years ago

timothyao commented 2 years ago

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.

berkayhh commented 1 year ago

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

timothyao commented 1 year ago

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