Пример #1
0
/*--------------------------------------------------------------------------------*/
bool PostgresDatabase::TableExists(const AString& name)
{
	SQLQuery *query = NULL;

	if ((query = RunQuery(AString("select count(*) from %").Arg(name))) != NULL) {
		bool success = query->GetResult();
		delete query;
		return success;
	}

	return false;
}
Пример #2
0
/*--------------------------------------------------------------------------------*/
bool PostgresDatabase::CreateTable(const AString& name, const AString& columns)
{
	AString sql;
	SQLQuery *query = NULL;
	uint_t i, n = columns.CountColumns();

	sql.printf("create table %s (", name.str());
	for (i = 0; i < n; i++) {
		AString column = columns.Column(i);
		if (i > 0) sql.printf(", ");
		sql.printf("%s %s", column.Word(0).str(), GetColumnType(column).str());
	}
	sql.printf(")");

	if ((query = RunQuery(sql)) != NULL) {
		bool success = query->GetResult();
		delete query;
		return success;
	}

	return false;
}