Page 1 of 1

Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets

Posted: Tue Jun 22, 2010 5:22 pm
by evstevemd
Now you know that wx is toolkit of my choice, It doesn't support Database per se. I hesitate to use Databaselayer as it seems not to be maintained for long though it works. I need to use something that it seems to be maintained.

I saw Pocco supports ODBC and other MySQL stuffs above. So anyone using above (or anything else for database?) I need OSS for that but that shows it will be maintained

Thanks :P

Posted: Wed Jun 23, 2010 1:31 pm
by evstevemd
Anyone using or have info on any of the above?
Any other solution than databaselayer?

Posted: Wed Jun 23, 2010 9:12 pm
by stahta01

Posted: Thu Jun 24, 2010 5:12 am
by evstevemd
stahta01 wrote:http://forums.wxwidgets.org/viewtopic.php?t=25142

wxsqlite and Debea


Tim S.
So is Debea stable for production?
What Applications use it?

Posted: Thu Jun 24, 2010 12:17 pm
by BuschnicK
I'm using SOCI (http://soci.sourceforge.net/) with moderate success. It features a nice interface and adequate performance. However some of the more useful backends aren't officially supported (ODBC,mySQL). Also, my biggest gripe with it - no unicode support.

Posted: Mon Sep 27, 2010 3:51 pm
by evstevemd
I'll go for PoCo

Posted: Tue Sep 28, 2010 10:56 am
by evstevemd
I hope I will go for POCO or MySQL++ or I will wait for MySQL C++ Connector to be MinGW capable

Re:

Posted: Fri Mar 09, 2012 4:24 pm
by evstevemd
BuschnicK wrote:I'm using SOCI (http://soci.sourceforge.net/) with moderate success. It features a nice interface and adequate performance. However some of the more useful backends aren't officially supported (ODBC,mySQL). Also, my biggest gripe with it - no unicode support.
After wondering here and there I found the only free DB component that will suit my needs is SOCI (I need PGS/MySQL But POCO does not Support PGS out of the Box).
I'm struggling to get used to SOCI so I'm trying to connect to server and retrieve databases. I cannot find any document on what to use (trying to pass connection string without service).

Can you help me with how I can do that? Examples at soci site assumes you have database already.
Thanks!

Re: Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets

Posted: Fri Mar 09, 2012 6:57 pm
by RobP
The thing to remember about SOCI is that it is NOT a full database abstraction, it only abstracts the connection, query, and result. For anything else (table listing, column inspection) you will need to issue any vendor specific (ie. mysql, postgres) commands.

This is an example that will query a MySQL database using the SOCI library. The example will attempt to connect to MySQL and execute a query to get the list of databases. This example will use dynamic binding (where the number and types of columns is not known at compile time; as in a "SELECT * FROM users type query).

Code: Select all

 #include <soci.h>
 #include <soci-mysql.h>
 #include <stdio.h>
 
 int main() {
	 try {
		soci::session session(*soci::factory_mysql(), "db=mysql user=root password='' host=127.0.0.1 ");
		std::string query = "-- a query\n SHOW DATABASES;";
		soci::statement stmt(session);
		stmt.alloc();
		stmt.prepare(query);
		stmt.define_and_bind();
		soci::row row;
		stmt.exchange_for_rowset(soci::into(row));
		bool good = stmt.execute(true);
		if (good) {
			const soci::column_properties& props = row.get_properties(0);
			printf("%s\n", props.get_name().c_str());
		}
		while (good) {
			printf("%s\n", row.get<std::string>(0).c_str());
			good = stmt.fetch();
		}
		stmt.clean_up();
		session.close();
	}
	catch (std::exception const& e) {
		printf("Error: %s\n", e.what());
	}
	return 0;
}

Re: Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets

Posted: Sat Mar 10, 2012 6:16 am
by evstevemd
RobP wrote:The thing to remember about SOCI is that it is NOT a full database abstraction, it only abstracts the connection, query, and result. For anything else (table listing, column inspection) you will need to issue any vendor specific (ie. mysql, postgres) commands.

This is an example that will query a MySQL database using the SOCI library. The example will attempt to connect to MySQL and execute a query to get the list of databases. This example will use dynamic binding (where the number and types of columns is not known at compile time; as in a "SELECT * FROM users type query).

Code: Select all

 #include <soci.h>
 #include <soci-mysql.h>
 #include <stdio.h>
 
 int main() {
	 try {
		soci::session session(*soci::factory_mysql(), "db=mysql user=root password='' host=127.0.0.1 ");
		std::string query = "-- a query\n SHOW DATABASES;";
		soci::statement stmt(session);
		stmt.alloc();
		stmt.prepare(query);
		stmt.define_and_bind();
		soci::row row;
		stmt.exchange_for_rowset(soci::into(row));
		bool good = stmt.execute(true);
		if (good) {
			const soci::column_properties& props = row.get_properties(0);
			printf("%s\n", props.get_name().c_str());
		}
		while (good) {
			printf("%s\n", row.get<std::string>(0).c_str());
			good = stmt.fetch();
		}
		stmt.clean_up();
		session.close();
	}
	catch (std::exception const& e) {
		printf("Error: %s\n", e.what());
	}
	return 0;
}
Thank you Rob.

Re: Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets

Posted: Thu Oct 11, 2012 5:56 am
by ONEEYEMAN
Hi, Steve,
Why not use SQLite?

Thank you.

Re: Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets

Posted: Thu Oct 11, 2012 5:30 pm
by evstevemd
ONEEYEMAN wrote:Hi, Steve,
Why not use SQLite?

Thank you.
Because I need support for not only SQLite3 of which I could just use wxSQLite3 but also MySQL and PostGreSQL

Re: Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets

Posted: Thu Oct 11, 2012 5:38 pm
by evstevemd
RobP wrote:The thing to remember about SOCI is that it is NOT a full database abstraction, it only abstracts the connection, query, and result. For anything else (table listing, column inspection) you will need to issue any vendor specific (ie. mysql, postgres) commands.

This is an example that will query a MySQL database using the SOCI library. The example will attempt to connect to MySQL and execute a query to get the list of databases. This example will use dynamic binding (where the number and types of columns is not known at compile time; as in a "SELECT * FROM users type query).
This example have taken me far but I have failed on the way. I want to have a Connection class that does connect to server, no problem. In the same class I have two methods, ExecuteQuery() for select and like statement and ExecuteUpdate() for update insert and like Queries. I have problem on encapsuating resultset into another class. I want something like below where ResultSet is my class that will store soci::rows and other info/methods
bool ExecuteUpdate(const wxString& sql, ResultSet& rs)

so that I use something like
ResultSet rs;
wxString sql = wxT("SELECT * FROM mytable;");
ConnClass* conn = new ConnClass(....parameters....);
if(conn->IsConnected())
{
conn->ExecuteQuery(sql, rs);
}
if(rs.Ok())
{
//do something with Resultset
}

I tried a failed approach here at SO

Re: Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets

Posted: Sat Oct 13, 2012 7:11 pm
by evstevemd
Argh! I had to go with DatabaseLayer. Soci is nice but many things are too hard for newbie.
I hope It will help me :)