First steps in understanding databases lazarus / 16-Databases ---------------------------------------------------------------------- sanric · 2023-07-07 13:39 Hello there, I'm very new to Lazarus/FPC and I'm trying to understand the mechanics of SQLite: coming from XOJO/RealStudio language, I find working with these tools very difficult and the tutorials online are not so well- made, in my humble opinion. It's difficult for me to understand the differences between queries and transactions, the difference between Commit and ExecuteDirect and so on. As you may have guessed by now, I've got a lot of confusion in my head. I'd like to create an application with a form in which there are two buttons: one that create a database and one which puts datas inside it. No more than this: still I'm struggling to get things done. I've watched the tutorials on the wiki but it's rather confusing: can you help me with some useful resources? Many thanks to everyone! ---------------------------------------------------------------------- Handoko · 2023-07-07 19:21 Hello sanric, Welcome to the forum. Learning database can be difficult for newbies. Have you able to use dbf? If you haven't, maybe you can start from dbf. Dbf is a very easy to learn database, it requires no installation on user computer. As far as I know dbf version 3 can handle up to 128 fields and 4 billions of records. It should be enough if you're building simple programs. After you understand how to use dbf, it should be easier for you to learn the other more powerful databases, which have better data integrity, security and support for multiple user connections from a network. If you're interest to try dbf, in the link below: https://wiki.freepascal.org/Portal:HowTo_Demos In the User Interface section in the link above, you can find "Searchable StringGrid". There has some demos showing how to load data and showing it on a string grid. And here has a demo showing how to create dbf file and data runtime: https://forum.lazarus.freepascal.org/index.php/topic,57291.msg425930.h tml#msg425930 And here is the TDbf tutorial: https://wiki.lazarus.freepascal.org/Lazarus_Tdbf_Tutorial If you want to try dbf, you need to enable it in your Lazarus first, read here for more information: https://forum.lazarus.freepascal.org/index.php/topic,60227.msg449835.h tml#msg449835 ---------------------------------------------------------------------- cdbc · 2023-07-07 20:06 Hi You could try to download this demo and study the code, it looks interesting: https://gist.github.com/pakLebah/277e0875a9ff50b9186fa9e166667add This is a console program, but the princip is the same for gui's... I just googled "free pascal sqlite3 example" and this was result no. 2 (the first was fpc-wiki tutorial on working with sqlite)  edit: https://www.tweaking4all.com/software-development/lazarus- development/lazarus-pascal-getting-started-with-sqlite/ ...and a video: https://www.youtube.com/watch?v=0BUsi54gy-c Regards Benny ---------------------------------------------------------------------- Zvoni · 2023-07-10 06:41 SQLite is a good choice to start out (forget DBF and/or access) As to your problem understanding Queries, Transactions etc.: This doesn't have anything to do with Lazarus/Freepascal per se, but are basic Database-Technologies. I'd advise to read up on that, otherwise you'll always get stumped by it. Since you're coming from XOJO, i'd hazard a guess that you never had to use a "transaction", because XOJO did it for you invisibly in the background. Freepascal offers you the same. Look for "implicit transaction" or something like that ---------------------------------------------------------------------- SymbolicFrank · 2023-07-10 12:15 SQL isn't hard, if you mostly use it to store and extract data. It becomes more complicated if you want to manipulate the data through SQL, but you can do that in code as well. There are some basic statements, create, drop, insert, update, delete and select. Those are all you need. For SQLite: drop the .dll or .so in both you application directory and the Lazarus directory, and you can start with it. Make a form with a TMemo and an "Execute" button. Add a TSQLConnection, TSQLTransaction and TSQLQuery. In the properties, refer them to each other. and then follow the wiki.