List:General Discussion« Previous MessageNext Message »
From:Lars Nilsson Date:June 7 2012 3:29am
Subject:Re: Connect to MySQL server from a c++ application
View as plain text  
On Wed, Jun 6, 2012 at 10:41 PM, Simon Walter <simon@stripped> wrote:
> However, memory leaks are not acceptable. So I am open to suggestions. What
> do other c++ programmers use?

I've been happy using SQLAPI++ (http://www.sqlapi.com/) where I work.
Commercial and not open source, but it's cross-platform and supports a
dozen or so different databases.

One of the example programs (without comments and the wrapping try/catch block)

        con.Connect("test", "tester", "tester", SA_Oracle_Client);
        cmd.setConnection(&con);
        cmd.setCommandText(
            "Insert into test_tbl(fid, fvarchar20) values(:1, :2)");
        cmd.Param(1).setAsLong() = 2;
        cmd.Param(2).setAsString() = "Some string (2)";
        cmd.Execute();
        cmd << (long)3 << "Some string (3)";
        cmd.Execute();
        con.Commit();

Simply replace SA_Oracle_Client with SA_MySQL_Client, etc, and you'll
be working against MySQL. Only requirement is that the dll/so
libraries for each database you want to connect to are installed
properly.

Lars Nilsson
Thread
Connect to MySQL server from a c++ applicationSimon Walter7 Jun
  • Re: Connect to MySQL server from a c++ applicationLars Nilsson7 Jun
  • Re: Connect to MySQL server from a c++ applicationSimon Walter7 Jun
    • Re: Connect to MySQL server from a c++ applicationLars Nilsson7 Jun
      • Re: Connect to MySQL server from a c++ applicationClaudio Nanni7 Jun
        • Re: Connect to MySQL server from a c++ applicationBaron Schwartz7 Jun
        • Re: Connect to MySQL server from a c++ applicationLars Nilsson7 Jun
  • Re: Connect to MySQL server from a c++ applicationSimon Walter8 Jun
    • Re: Connect to MySQL server from a c++ applicationClaudio Nanni8 Jun