I need to create a program for Linux, in which I need a database. After reading many sources, I could not find the options where the database is located in the program itself. Everywhere it says only about accessing the database, which is separate from the program, with the help of commands. I myself work in Qt Creator in C ++ . Please tell me how you can create a database in the program itself.
2 answers
Can you please tell how you can create a database in the program itself
Depends on the life of the base.
If it is limited by the running time of the program - keep everything in memory, choosing the appropriate data structures, there are no problems with this (well, except for the limitations on available memory).
If you need to save data between program launches, then you cannot do without external storage. Theoretically, you can modify the executable file itself, but I don’t even want to discuss this option.
Look for a start towards SQLite . Qt is able to work with it "out of the box", and there are libraries that are sishnye and plus. By itself, the database represents one file that does not require any additional software on the client machine.
Judging by the wording of the question, if I am mistaken, correct me, you just started learning programming, and this is one of your assignments.
The term "Database" is a repository of information with an interface for programmed content management. She, too, if not strange, is itself a "program."
"Create a program" - this probably means writing a custom application that works with the database.
"create a database in the program itself" - this is likely to use the built-in database connected as a module. SQLite is most commonly used for this purpose.
To understand what is happening and how it is done, you probably need step-by-step instructions:
- run Qt Creator
- if you have Qt Creator in Russian, then I would recommend switching to English. To do this, select the menu "Tools" -> "Options ..."
- in the "Parameters" window on the left, select "Environment" -> open the "Basic" tab -> select in the drop-down list "English" -> press the "OK" button -> restart Qt Creator
- in the Qt Creator menu, select "File" -> "New File or Project ..." (Ctrl + N)
- in the "Projects" section, select "Applications" -> in the second column, select "Qt Widgets Application"
- press the "Choose" button
- in the field "Name" enter: DatabaseLoginForm and click "Next" (2 times)
- in the "Base Class" field, select "QDialog" -> click "Next" -> click "Finish"
- Download the source code of the project (the "Download ZIP" button on the right-bottom): https://github.com/8Observer8/DatabaseLoginForm
- we replace files of the current project with files from downloaded
- press Ctrl + R to start the program
the original is here: http://www.prog.org.ru/topic_26665_0.html