implemented postgres table exists
This commit is contained in:
parent
640dcfadb6
commit
a436af5293
|
|
@ -134,7 +134,13 @@ sql::record postgres_connection::describe(const std::string &table)
|
||||||
|
|
||||||
bool postgres_connection::exists(const std::string &table_name)
|
bool postgres_connection::exists(const std::string &table_name)
|
||||||
{
|
{
|
||||||
return false;
|
std::string stmt("SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = '" + table_name + "'");
|
||||||
|
|
||||||
|
PGresult *res = PQexec(conn_, stmt.c_str());
|
||||||
|
|
||||||
|
throw_postgres_error(res, conn_, "postgres", stmt);
|
||||||
|
|
||||||
|
return sql::to_long_long(PQcmdTuples(res)) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue