Open normidar opened 4 years ago
Can you open a connection and run SELECT 1;
on it?
Can you open a connection and run
SELECT 1;
on it?
when I run SELECT 1;
, it is no error.
And when I unclose the database link it is no error too.
is it can not close after DELETE
?
At one point you are closing the connection. Could you please share how you are using calling it?
At one point you are closing the connection. Could you please share how you are using calling it?
my code is:
.....
var sql = 'DELETE FROM $table WHERE "' + idName +'" = ' + id +';';
await _conn.query(sql)
if(!_conn.isClosed)await _conn.close();
the _conn
is PostgreSQLConnection
class.
I'm using Postgres in this website https://www.elephantsql.com/
is it can not close after the drop and the delete? when I close after the drop it has an error too.
Do you do anything else between opening the connection and querying it? Please provide full example (without the connection string).
Do you do anything else between opening the connection and querying it? Please provide full example (without the connection string).
LinkSets card = LinkSets( 'raja.db.elephantsql.com', '5432', 'wabjtpfp', 'Q5q05nP9mcDUY9V3bWidtwegWxU9IO_J', 'wabjtpfp', ); Future<String> getConn() async{ _conn = PostgreSQLConnection( card.host, int.parse(card.port ?? 5432), card.db, username: card.user, password: card.psw, ); await _conn.open(); return _conn.isClosed.toString(); } Future deleteTable(String table)async{ _getRows('DROP TABLE ' + table + ';'); } Future<List<List<dynamic>>> _getRows(String sql)async{ List<List<dynamic>> results = await _getRealRows(sql); return results; } Future<PostgreSQLResult> _getRealRows(String sql){ return _conn.query(sql); } Future closeDatabase()async{ if(!_conn.isClosed)await _conn.close(); }
await link.getConn();
await link.deleteTable('ccc');
await link.closeDatabase();
you can link it whit this setting, maybe it is wrong in the server, I do not know.
return
in deleteTable
, e.g. return _getRows('DROP TABLE ' + table + ';');
I'd suggest to add unawaited_futures
to you analysis_options.yaml
as an extra lint.
delete from ccc where id=1; when I run the delete from ccc where id=1 and throw an error. it is like this: ERROR: Bad state: StreamSink is closed