Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets Topic is solved

In this forum you can discuss database related issues which can be wxWidgets related, but also generic in nature.
Post Reply
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

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

Post 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
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Post by evstevemd »

Anyone using or have info on any of the above?
Any other solution than databaselayer?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 548
Joined: Fri Nov 03, 2006 2:00 pm

Post by stahta01 »

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Post 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?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
BuschnicK
Experienced Solver
Experienced Solver
Posts: 80
Joined: Thu Oct 13, 2005 1:30 pm
Contact:

Post 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.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Post by evstevemd »

I'll go for PoCo
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Post by evstevemd »

I hope I will go for POCO or MySQL++ or I will wait for MySQL C++ Connector to be MinGW capable
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re:

Post 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!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
RobP
In need of some credit
In need of some credit
Posts: 6
Joined: Sun Jan 04, 2009 6:56 am
Location: software engineer
Contact:

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

Post 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;
}
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

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

Post 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.
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

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

Post by ONEEYEMAN »

Hi, Steve,
Why not use SQLite?

Thank you.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

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

Post 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
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

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

Post 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
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

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

Post 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 :)
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Post Reply