createPostgresTable function
Implementation
FutureOr createPostgresTable(
Map fields,
String tableName,
String dbName,
String host,
int port,
String username,
String password,
) async {
PostgreSQLConnection conn = PostgreSQLConnection(host, port, dbName,
username: username, password: password);
await conn.open();
if (fields.length != 0) {
var key = fields.keys.map((key) => '$key ${fields[key]}').join(', ');
var startSql = 'CREATE TABLE IF NOT EXISTS $tableName ($key)';
try {
await conn.query(startSql);
conn.close();
} on PostgreSQLException catch (e) {
print(e);
}
} else {
print(
'[ INFO ] Unknown error!! Please check the "model_definitions.yaml" file for any corrections.');
}
}