Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets Topic is solved
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets
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
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
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
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.
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re:
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).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.
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
-
- 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
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 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;
}
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets
Thank you Rob.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; }
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets
Hi, Steve,
Why not use SQLite?
Thank you.
Why not use SQLite?
Thank you.
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets
Because I need support for not only SQLite3 of which I could just use wxSQLite3 but also MySQL and PostGreSQLONEEYEMAN wrote:Hi, Steve,
Why not use SQLite?
Thank you.
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets
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/methodsRobP 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).
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Pocco, MySQL++, MySQL Connector C++, ODBC and wxWidgets
Argh! I had to go with DatabaseLayer. Soci is nice but many things are too hard for newbie.
I hope It will help me
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?