Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PostgreSQL+;飞奔_Postgresql_Dart - Fatal编程技术网

PostgreSQL+;飞奔

PostgreSQL+;飞奔,postgresql,dart,Postgresql,Dart,我有以下代码: void main() async { connection = PostgreSQLConnection('localhost', 5432, 'db', username: 'postgres', password: '12345'); await connection.open(); //... // some http handler that have next code inside: List<List<dynamic>

我有以下代码:

void main() async {
  connection = PostgreSQLConnection('localhost', 5432, 'db', username: 'postgres', password: '12345');
  await connection.open();
  
  //... 
  // some http handler that have next code inside:
  List<List<dynamic>> result = await connection.query(body['sql']).timeout(Duration(seconds: 90));

这很奇怪,因为在
query
上我有超时
90秒。所以它发生在
连接上。但我只在
main
中打开一次连接


有人能解释一下这是怎么发生的吗?如何修复它?

PostgreSQLConnection有参数:timeoutInSecondsqueryTimeoutInSeconds,它们都默认为30。我建议您使用它们,而不是将来的超时。

“而不是将来的超时”。您能解释更多细节吗?为什么我不应该在这里使用未来超时?Postgres驱动程序有内部超时(TimeOutingSeconds,QueryTimeOutingSeconds),它们的超时时间比您的要快,因为默认情况下它们是30秒,而您的是90秒。所以你需要增加这些。当你这样做的时候,就没有必要使用你未来的一个。但我需要哪一个超时?
连接
查询
超时之间有什么区别?当驱动程序打开到Postgres的连接时,会使用连接超时。执行查询时使用查询超时。从您的示例中,我假设您需要使用查询超时。
TimeoutException after 0:00:30.000000: Future not completed