我尝试使用PostgresClientKit从PostgreSQL数据库中获取行数,但我收到以下错误:类型为"Any"的值没有成员"int"。
这是密码
let rows = fetchSQL(statement: "SELECT count(*) FROM ag_graph WHERE name='" + graphName + "'", connection: connection);
let row_counts = rows[0] as! [Any];
let count = try row_counts[0].int();
if count < 1{
// My Code
}
我试过打印行。它是
1
fetchSQL函数的定义如下
func fetchSQL(statement:String, connection:Connection)-> [Any]{
var rows:[Any] = [];
do{
let statement = try connection.prepareStatement(text: statement)
defer { statement.close() }
let cursor = try statement.execute()
defer { cursor.close() }
for row in cursor {
rows.append(try row.get().columns);
}
}catch{
print(error)
}
return rows;
}
1条答案
按热度按时间jmo0nnb31#
这样试试,可能会有帮助。