【发布时间】:2018-11-30 07:33:58
【问题描述】:
我使用postgres 库来处理数据库。我有一个非常大的数据库。我需要更改列中的字符。我是这样做的:
void replace(String col, String from, String to) async {
String queryStr = "UPDATE $tab SET $col = replace($col, '$from', '$to');";
await connection.query(queryStr);
}
如果数据库的行数超过 1,000,000 行,我会收到错误消息:
未处理的异常:0:00:30.000000 之后的 TimeoutException:未来不会 完全的 0 _PostgreSQLConnection&Object&_PostgreSQLExecutionContextMixin._enqueue (包:postgres/src/connection.dart:402:24) 1 _PostgreSQLConnection&Object&_PostgreSQLExecutionContextMixin.query(包:postgres/src/connection.dart:318:12) 2 PG.replace (file:///home/vas/IdeaProjects/infovizion_platform/pg/bin/pg.dart:50:22) 3 主要 (file:///home/vas/IdeaProjects/infovizion_platform/pg/bin/main.dart:81:14) 4 _start隔离。 (dart:isolate/runtime/libisolate_patch.dart:287:32) 5 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
当我手动执行相同的请求时,没有错误。
我该如何解决这个问题?
【问题讨论】:
-
你必须增加或设置超时时间
-
@comrad 如何在dart中设置执行限制?
-
让你的方法返回一个Future。 Future.timeout(new Duration(seconds: 100000),...);
标签: sql database postgresql dart dart-pub