List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:August 25 2008 4:34pm
Subject:Re: [OT] Embedded MySQL in C++
View as plain text  
Deepak Shrestha wrote:
> What do I need to implement embedded MySQL server in C++?

First, RTFM: http://dev.mysql.com/doc/refman/5.1/en/libmysqld.html

I pointed you to the v5.1 version of this page because libmysqld got 
removed from v5.0, then put back in v5.1.  I don't know why.

MySQL++ *may* work transparently with libmysqld.  I haven't tried it, 
but it looks like you need only two minor modifications relative to the 
normal use of MySQL++, with a remote server:

1. You do still need a Connection object, but you don't make it try to 
connect to a remote server.  Just use the default ctor, which will call 
mysql_init() for you.  This in turn calls mysql_library_init(), as 
required by libmysqld.  Beyond this point, you do still need the 
Connection object; the object has to live as long as you need access to 
the database.  Think of it as a database handle in this context.

2. Before your program dies, you need to call mysql_library_end().  I 
suspect if you don't, any lingering DB writes won't get committed safely 
to disk.  MySQL++ doesn't provide a wrapper for mysql_library_end(), but 
you can call it directly.

That addresses two of the four functions mentioned on that MySQL manual 
page I pointed you to.  MySQL++ provides wrappers for the other two: 
Connection::thread_start() and Connection::thread_end().  These are 
static methods, not object methods.
Thread
[OT] Embedded MySQL in C++Deepak Shrestha25 Aug
  • Re: [OT] Embedded MySQL in C++Warren Young25 Aug
    • Re: [OT] Embedded MySQL in C++Deepak Shrestha26 Aug