createTable method

Future createTable(
  1. String tableName,
  2. Map<String, dynamic> fields
)

Implementation

Future createTable(String tableName, Map<String,dynamic >fields) async {
  // Create a table
  var query =
      '''CREATE TABLE IF NOT EXISTS $tableName (id int NOT NULL AUTO_INCREMENT PRIMARY KEY,${fields.entries.map((entry) => '${entry.key} ${entry.value}').join(',')})''';
   /*  await mySqlConnection?.query(
      'CREATE TABLE users (name varchar(255), email varchar(255), age int)');*/
  await mySqlConnection!.query(query);
}