Just more a general question I can't seem to find a definite answer on.
But what is a good SQL wrapper for C++ that allows me to call queries?
I'm used to Oracle, but i've used MYSQL before aswell.
And how would you call something such as an insert statement (for example) in one?
Personally I love SOCI, simple and easy to use, just follow the link for easy example code and a much better explanation of what SOCI is all about then I could put in this answer. I use this for all of my C++ SQL development work.
Related
I recently asked this question https://softwareengineering.stackexchange.com/questions/129076/go-instead-of-c-c-with-cgo and got some very interesting input. However there's a mistake in my question: I assumed cgo could also be used to access c++ code but that's not possible. Instead you need to use SWIG.
The go faq says "The cgo program provides the mechanism for a “foreign function interface” to allow safe calling of C libraries from Go code. SWIG extends this capability to C++ libraries. "
my question:
Is it possible to access high-level c++ frameworks such as QT with SWIG + Go and get productive? I'd like to use Go as a "scripting language" to utilize c++ libraries.
Have you any experience with go and swig? Are there pitfalls I have to be aware of?
Update/Answer: I've asked this over IRC too and I think the question is solved:
SWIG is a rather clean way of interfacing c++ code from other languages. Sadly matching the types of c++ to something like go can be very complex and in most cases you have to specify the mapping yourself. That means that SWIG is a good way to leverage an existing codebase to reuse already written algorithms. However mapping a library like Qt to go will take you ages. Mind it's surely possible but you don't want to do it.
Those of you that came here for gui programming with go might want try go-gtk or the go version of wxWidgets.
Is it possible? Yes.
Can it be done in a reasonably short period of time? No.
If you go back and look at other projects that have taken large frameworks and tried to put an abstraction layer on it, you'll find most are "incomplete". You can probably make a fairly good start and get some initial wrappers in place, but generally even the work to get the simple cases solved takes time when there is a lot of underlying code to wrap, even with automated tools (which help, but are never a complete solution). And then... you get to the nasty remaining 10% that will take you forever (ok, a really really long time at least). And then think about how it's a changing target in the first place. Qt, for example, is about to release the next major rewrite.
Generally, it's safest to stick to the framework language that the framework was designed for. Though many have language extensions within the project itself. For example, for Qt you should check out QML, which provides (among many other things) a javascript binding to Qt. Sort of. But it might meet your "scripting" requirement.
A relevant update on this issue: it is now possible to interact with C++ using cgo with this CL, which is merged for Go 1.2. It is limited, however, to C-like functions calls, and classes, methods and C++ goodies are not supported (yet, I hope).
I used to develop some Perl programs using Fry::Shell. I think it is very powerful and easy to use.
For one of my C++ projects I need to create a command line client. The idea is to create a TUI like the one found in routing hardware.
Does such a framework exist ?
You can keep using Fry::Shell. It's not much of a hassle to call Perl from C++. Here's a starting point for that, there might be a better way to do it.
EDIT: I just found a project on Github. It's written in C and seems pretty much dead, but try it out, it might be useful. Even if it's not, since it's open source, you can use it as a starting point. It claims to provide a Cisco-like interface, which should suit you pretty well.
I have some problem writing postgres functions in C++ while following the guides for C: C-Language Functions. I found that most postgres functions are written in C instead C++, but I have to use a lib that is written in C++, so I chose C++. My question is, is there anything to notice when writing in C++? It's common to write makefiles using pgxs, so how should I write the makefile to make it work? Thanks.
If you can avoid doing it, do so. PostgreSQL doesn't mix especially well with C++. It's possible, as shown by PostGIS, but it's not overly fun.
If you can, write or generate a pure C wrapper to your C++ library and use that wrapper to interact with the library. That won't be practical if it's heavily template based (eg: boost) or uses other more advanced C++ features, but works well if it's just C-with-objects style code. SWIG can help generate wrappers for you.
If you'd prefer to avoid the wrapper approach or if your library is a bit too complex, too exception-reliant, etc for that then you should read this PostgreSQL manual entry.
Search the PostgreSQL mailing list for more discussion on this topic.
What are the suitable database for Visual Studio C++?
How could I connect a database to C++?
Your choice of a database is fully dependent on your requirements. SQLite offers a nice and simple interface.
Beginners to Microsoft C++ should probably stick with SQL Server Express, since it is designed specifically to work with Visual Studio.
If you need a local database just for your application then check out SQLite. They have a C++ library that is quite easy to use and you interact with it via normal SQL syntax.
Most, if not all, popular DBMS provide a C connector. Some even provide a C++ one (generally a wrapper of the C driver).
So, I suggest you start by looking at which DBMS you want to use, then browse their documentation for how to obtain and use their driver.
I've been spending more and more time writing DB Wrappers for Oracle access. This seems to be quite generic procedure, and I was wondering is there already are code generators that generate access routes to Oracle PL/SQL Stored Procedures in C++?
I'm looking for a configurable generation tool that would be capable of managing connection and handle multiple threads if needed. I'm aware of OCI/OCCI and Oracle C++ extension, but I'm looking for a pure self-contained C++ accessor generation tool.
Any advice welcome.
Thank You!
You might also want to have a look at:
http://orclib.sourceforge.net
http://otl.sourceforge.net/
http://www.codeguru.com/cpp/data/mfc_database/oracle/article.php/c4305
We use the SQLAPI (http://www.sqlapi.com/) for all of our C++ development w/ Oracle. It I think is a more efficient wrapper for the OCI (though as another person pointed out, the OCCI is prety good). Another advantage for the SQLAPI is that it also supports other database platforms. We use it for MySQL as well and having that abstraction layer in between our application and database layers certainly simplifies things quite a bit.