#include <libgda/libgda.h>

int main()
{
	char table_name[100];
	printf("Table Name: ");
	fflush(stdout);
	scanf("%s", table_name);

	gda_init();

	GdaConnection* conn = gda_connection_open_from_string("SQLite", g_strdup_printf("DB_DIR=.;DB_NAME=%s", table_name), "", GDA_CONNECTION_OPTIONS_NONE, NULL);
	GdaServerProvider* provider = gda_connection_get_provider(conn);

	GdaServerOperation* operation = gda_server_provider_create_operation(provider, conn, GDA_SERVER_OPERATION_CREATE_TABLE, NULL, NULL);

	gda_server_operation_set_value_at(operation, table_name, NULL, "/TABLE_DEF_P/TABLE_NAME");
	gda_server_operation_set_value_at(operation, "id", NULL, "/FIELDS_A/@COLUMN_NAME/0");
	gda_server_operation_set_value_at(operation, "int", NULL, "/FIELDS_A/@COLUMN_TYPE/0");
	gda_server_operation_set_value_at(operation, "TRUE", NULL, "/FIELDS_A/@COLUMN_PKEY/0");

	gda_server_provider_perform_operation(provider, conn, operation, NULL);

	gda_connection_update_meta_store(conn, NULL, NULL);
	GdaDataModel* data = gda_connection_get_meta_store_data(conn, GDA_CONNECTION_META_TABLES, NULL, 0);
	gda_data_model_dump(data, stdout);

	return 0;
}
