Where to store data? - c++

I have created a c++ program but now I need to store on the hard disk permanently some settings about the program.
Where do I have to store this data ?
In a sqlite database ?
In the windows registry ( if linux ? ) ?
In a XML file
In other files ?

It completely depends how much information it is and for which platform.
Viable options are a .ini file http://en.wikipedia.org/wiki/INI_file#Accessing_INI_files and for more data a SQLite database. I'm not a big fan of XML files.

It depends on the type and size of data. For small and less complex data simple text files are better. for complex data you can use XML or sqlite database. If you need to write complex queries go for sqlite. It stores data in files but will give better query options.

Modern applications use the system registry to store configuration information.
See the windows article: Using the Registry in a C++ Application
http://msdn.microsoft.com/en-us/library/ms838625.aspx

Related

C++ VCL Interrogating .xlsb Excel database

I need some help for interrogating an xlsb database (file) from a VCL C++ program; (using C++Builder XE2) mainly, i would like to query the data inside for simple viewing (its on the same machine, no networking involved), and i don't need to modify it ! so i would like to know :
Which control to use for connecting to an xlsb database
(TDatabase, dbExpress ?)
How to use that control for the purpose
of reading the data, (same as SQL?)
The difference between the regular xsl and xslb, and are they used in the same manner ?
I did some research before asking, but the information about that is pretty scarce !
(i'm on Win 7 64bit)
Thank you all !
Never tested it with these files but i believe you can use a TADOConnection and then user Microsoft OLE DB Provider for ODBC Drivers as the data provider, i know it can use access and excel files as a source, personally i have only ever used it for access files, but it might do what you want.

Making data entry fields remember their values form one run to the next

I'm writing a C++ MFC program, and I see programs that remember the last input values for some fields from one program run to the next. I could do this by saving it to a file and loading that and then repopulating, but is there another, quicker way of doing this, as I think I remember reading somewhere that these values could be stored in the registry? If anyone has an example or personal experiences, I would be very interested.
Thanks,
James
There are many options out there
I personally don't like the registery and prefer to keep my program portable.
so what I can think of right now are
1- ini files
2- property files
3- SQL server
4- you can also synchronize the user settings via web server, but as #Jeeva mentioned there are security considerations
Cheers
It all depends on what kind of values you want remember. If it is an configuration data you can use config files. If it is small application data you can use flat files with proprietary format. If it is huge data you can use a database like SQL Server.
Usually there is a debate about using ini file vs registry.
Other things you want to consider is whether the data will be used across network. Whether you need to encrypt.

Store MySQL table to file (sqlite?)

I wrote a C++/QT application that uses a mysql database for its data. It's using the mysql++ library. I now want it to be able to export and import its data to/from files.
I could write an own file format, but I'd like to elude this efford, if possible.
Is there an easy possibility to export a mysql table into a file and to reimport this file with C++?
I heard of sqlite, but as far as I read, migrating from mysql++ to sqlite is not that easy, because it includes a switch of the complete database backend.
You can use "LOAD DATA " and "SELECT ... INTO OUTFILE"
That should have great performance. You may not use the outfiles further as easily as you want.
The best way to export/import data from/to a database is xml files.

Qt / C++ - how to store configuration data

What is the best way to store application configuration in a Qt application?
If You store only list of name-value pairs QSettings class will suffice. It is cross platform and works well.
Check this page for more info:
http://doc.qt.io/archives/qt-4.7/qsettings.html
On the other hand if You have to store data in multiple tables (many params, many rows) I suggest You use Sqlite and QtSQL. Sqlite is ralational database that can be embeded in your application without the need of starting any servers or installing additional software. Sqlite sotres all tables in one *.db file. You can place each user's configuration in his home directory.
This link demonstrates how QtSQL library works:
http://doc.qt.io/archives/qt-4.7/sql-sqlstatements.html
Well, as you're using Qt anyway, why not using QSettings? You can use its default settings to save your configuration in platform specific default locations (e.g. Registry under Windows) or use it to write to classic INI files.

Best way to store data in C++

I'm just learning C++, just started to mess around with QT, and I am sitting here wondering how most applications save data? Is there an industry standard? Do they store it in a XML file, text file, SQLite? What about sensitive data that say accounting software would need to save? I'm just interested in learning what the best practices for this are.
Thanks
This question is way too broad. The only answer is it depends on the nature of the particular application and the data, and whether or not it is written in C++ has very little to do with it.
For example, user-configurable application settings are often stored in text files, but on Windows they are typically stored in the Registry. Accounting applications typically keep their data in a database of some sort.
There are many good ways to store application data (call it serialization).
Personally, I think for larger datasets, using an open format is much, much easier for debugging. If you go with XML, for example, you can store your data in an open form so that if you have file corruption issues (i.e. a client can't open your file for some reason), it's easier to find. If you have sensitive data in there, you can always encrypt it before writing it to file using key encryption. Microsoft, for instance, has gone from using a proprietary format to open xml in their office docs. They use .*x extension (.docx, .xlsx, etc). It's really just a compressed folder with xml files.
Using binary serialization is, of course, the industry standard at the moment for most standalone applications. Most likely that is because of the application framework they are using (such as MFC, which is old). If you take a look at most of the serialization techniques in modern application frameworks, XML serialization is very well supported.
First you need to clarify what kind of data you would like to save.
If you just want to save some application settings, use QSettings to save your settings to an INI file or registry.
If it is much more than just some application settings, go for XML files or SQL.
There is no standard practice, however if you want to use complex structured data, consider using an embedded database engine such as SQLite or Metakit, or Berkeley DB files. XML files would also do the job and be human readable/writable. Preferences can use INI files or the Windows registry, and so on. In short, it really depends on your usage pattern.
This is a general question. Like many things, the right answer depends on your application and its needs.
Most desktop applications save end-user data to a file (think Word and Excel). The format is up to you, XML, binary, etc. And if you can serialize/deserialize objects to file it will probably make your life easier.
Internal application data such as configuration files or temporary data might be saved to an XML file or an lightweight, local database such as SQLite
Often, "enterprise" applications used internally by a business will save their data to a back-end database such as SQL Server or Oracle. This is so all of the enterprise's data is saved to a single central location. And then it is available for reporting, etc.
For accounting software, you would need to consider the business domain and end users. For example, if the software is to be sold to large businesses you would probably use some form of a database to save data. Otherwise a binary file would be fine, perhaps with some form of encryption if you are really paranoid.
When you say "the best way", then you have to define what you mean by "good".
The problem is that various requirements conflict with each other, therefore so you can't satisfy all of them simultaneously.
For example, if one requirement is "concurrent multi-user access to the data" then this suggests using a database engine, but that conflicts with "as small as possible" and "minimize dependencies on 3rd-party software".
If a requirement is "portable data format" then this suggests XML, but that conflicts with "compact" and "indexed".
Do they store it in a XML file, text file, SQLite?
Yes.
Also, Binary files and relational databases.
Anything else?