#include <iostream>
#include "common.h"
#include "mysql.h"


int main()
{
	Mysql_DB db("localhost", "test", "test", "test");
	if (!db.connect()) return 1;

	Query stmt(db);

	if (!stmt.execute("create table if not exists test (f1 int, f2 varchar(32), index(f1))")) {
		cerr << "sql error " << db.error() << endl;
	}

	if (!stmt.execute("insert into test set f1=1,f2='"+db.escape("ahoj")+"'")) {
		cerr << "sql error " << db.error() << endl;
	}

	if (!stmt.execute("select * from test")) {
		cerr << "sql error " << db.error() << endl;
	}
	while (stmt.fetch_row()) {
		int i = 0;
		while (stmt.name(i)) {
			cerr << stmt.name(i) << "=" << stmt[i] << " ";
			i++;
		}
		cerr << endl;
	}
}
