Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets  [SOLVED]

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

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

Postby evstevemd » Tue Jun 22, 2010 5:22 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Postby evstevemd » Wed Jun 23, 2010 1:31 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

stahta01
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 235
Joined: Fri Nov 03, 2006 2:00 pm

Postby stahta01 » Wed Jun 23, 2010 9:12 pm

viewtopic.php?t=25142

wxsqlite and Debea


Tim S.

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Postby evstevemd » Thu Jun 24, 2010 5:12 am

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

BuschnicK
Experienced Solver
Experienced Solver
Posts: 80
Joined: Thu Oct 13, 2005 1:30 pm
Contact:

Postby BuschnicK » Thu Jun 24, 2010 12:17 pm

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: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Postby evstevemd » Mon Sep 27, 2010 3:51 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

  [SOLVED]

Postby evstevemd » Tue Sep 28, 2010 10:56 am

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Re:

Postby evstevemd » Fri Mar 09, 2012 4:24 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

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

Postby RobP » Fri Mar 09, 2012 6:57 pm

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: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

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

Postby evstevemd » Sat Mar 10, 2012 6:16 am

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 2791
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

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

Postby ONEEYEMAN » Thu Oct 11, 2012 5:56 am

Hi, Steve,
Why not use SQLite?

Thank you.

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

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

Postby evstevemd » Thu Oct 11, 2012 5:30 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

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

Postby evstevemd » Thu Oct 11, 2012 5:38 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

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

Postby evstevemd » Sat Oct 13, 2012 7:11 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]


Return to “Database Related”

Who is online

Users browsing this forum: No registered users and 1 guest