How to create offline database to be used with c++ - c++

I saw already some questions with similar topic but my one is more of a beginner question.
I have already some experience with C++ and Microsoft Access but never came across how to actualy create or (if its not possible) than how to use an offline database similar to Access.
For example:
MS Access has its own tables etc... so I am about to build a program that will need offline database.
I think that to use simple txt files would not be the right way... What is my next option? Is there a way how all other programmers do it? Or would I just have to use one of the database providers like MySQL?

I think some people use SQLite for this purpose. I don't know that much about it, but you can learn more here:
http://www.sqlite.org/about.html

If you are on a Microsoft stack, then you may want to give a try to SQL Server Compact.
Alternatively, you may want to use SQLite; it is not so integrated in the Microsoft ecosystem, but it is Open Source, and is widely used.

You can use the ODBC driver and link it with your database source file. Just read this:
http://msdn.microsoft.com/en-us/library/ca6axakh%28v=vs.80%29.aspx
After setup your source use odbc api in your c++ code in order to make your queries. Also you can try to use ORM solutions in order to access your database.
http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software

+1 for sqlite
If you're not actually interested in doing SQL-like queries, you could look at
Serialization (e.g. boost)
Boost Property Tree (focuses on structured config data, AFAICT)
LevelDB (highperformance key-value store by google)
Cf. also hints on memory-mapping standard containers here:
LevelDB vs. std::map

Related

Design of data storage C++ application (maybe relational database)

I need to store and load some data in a C++ application. This data is basically going to end up as a set of tables as per a relational database.
I write the data to tables using something like csv format, then parse them myself and apply the database logic I need in my C++ code. But it seems stupid to reinvent the wheel with this and end up effectively writing my own database engine.
However, using something like a MySQL database seems like massive overkill for what is going to be a single user local system. I have tried setting up a MySQL daemon on my Windows system and I found it rather complex and possibly even impossible without admin privileges. It would be a serious obstacle to deployment as it would need each user's system to have MySQL set up and running.
Is there a reasonable middle ground solution? Something that can provide me with a simple database, accessible from C++, without all the complexities of setting up a full MySQL install?
NB. I have edited this question such that I hope it satisfies those who have voted to close the question. I am not asking for a recommendation for a tool, or someone's favourite tool or the best tools. That would be asking which database engine should I use. I am asking for what tools and design patterns are available to solve a specific programming problem - i.e. how can I get access to database like functionality from a C++ program, without writing my own database engine, nor setting up a full database server. This is conceptually no different to asking e.g. How do I print out the contents of a vector? - it's just a bigger problem. I have described the problem and what has been done so far to solve it. My understanding from the On Topic Page is that this is within scope.
You can try sqlite.
Here are some simple code examples: https://www.tutorialspoint.com/sqlite/sqlite_c_cpp.htm

Which are suitable local database (easy to handle with C++) for a small data set

The computer has already been installed ORACLE. But I didn't try ORACLE before, I just use sqlite...So, for now I want to create a database locally, and just insert one table. I want to use a test C++ program to read and write in this database. Is there something useful for using API about this? BTW, in the computer I saw SQL plus and SQL developer, but I didn't find the DBCA, which I know can be used to create table...help me, thanks a lot!!
BTW, my supervisor wants to me to test different kinds of database, which will be written in my report. So I want to test different kinds of databases, for the data is quite small, just 100 lines in a table is enough, but it will be applied in a big program, so I need to try different kinds of database locally, and not difficult for me to use C++ API...Because I just know little about database. I need some suggestions, thank a lot!
While I wouldn't recommend Oracle for handling small data sets, I do have a pointer to C++ API documentation.
http://www.oracle.com/pls/db112/portal.portal_db?selected=5&frame=
... and scroll to the bottom of the page for links to further information.
There's a choice of either using C++ with Oracle OCI API, or using C++ with Oracle Pro*C precompiler. The precompiler actually does produce code that uses the OCI API.
I have done some work with the Pro*C precompiler (using C as the implementation language, though, not C++), and it wasn't too bad. OCI tends to be quite low-level, but apparently writing direct OCI code has its uses, too.

Database in a C++ Program

I've got a C++ program that needs to deal with a lot of typical database problems - looking at tables, inserting and deleting values, searching for records. All of the database information has to be stored locally. Let me emphasise that - I don't want to communicate with a server, I want the information to be stored on the user's computer.
Are there any libraries that can easily implement all this functionality, preferably in a SQL style syntax? Or what are some ways to easily and robustly implement this functionality?
You can use embedded DB.
I think SQLite is one of the more popular ones.
My personal preference would be SOCI, with a SQLite backend.
http://soci.sourceforge.net/
http://soci.sourceforge.net/doc/backends/sqlite3.html
http://www.sqlite.org/

Making SQL query from C++

I have connected to an MS Access database from my project. Now I want to make a query, for example to take out data from third and fourth column.
How can I write SQL query in C++/CPP, using visual studio 2008?
If you're using a framework like MFC, Qt, or wxWidgets, you probably want to use the database connection classes they already include.
If you're not using one of those, you probably want to look into another library specifically for the purpose, such as DTL or SOCI.
You can obviously write your own code to talk to the database via something like OLE DB or ODBC, but they both involve quite a lot of boiler-plate, so a library helps out a lot.

Alternatives to writing an ODBC driver

We are storing allot of time series data into our own proprietary "database". In the next version of our system we want to give our users a simple query mechanism to extract the raw data from the database (as a complement to the reports our system can create) by using standard tools.
I have looked at the possibility to write an ODBC driver, but it looks like quite a daunting task, especially when the use will be very simple select statements.
I would be grateful for any tips, ideas and/or recommendation of libraries, that could make this task a bit simpler.
Our platform is Windows and our dev. env. is visual studio 2010 (nativ C++)
A LINQ provider.
It depends on what makes your customers happy. Easier than an writing ODBC driver would seem to provide a library function that can parse simple SQL selects and deliver the result in whatever form desired.
It might be interesting to take a look at OData, exposing your data as an OData producer, you would then be able to allow your users to query it right away using the already available consumers, e.g. Linqpad.