THANK YOU! I can't believe it took me so long to integrate SQL databases into my workflow. It's so simple it feels like I was a caveman just mucking about in the dirt before. lol
This was a life saver for my current project. I was banging my head in dealing with loads of people in a world that i dont need to actively show but handle nonetheless and keep persistent over sessions. This just solved all my issues!
I would like to ask for some guidance on how to make this database accessible from different devices. My ideal scenario would be to have a mobile app where the database is online and every app can insert/remove data. I apologize if this is a basic question, but I am new to this topic. Thank you for the awsome video and your help.
Thank you for this. Edit: SQLite in user:/ seems the way to go, handling data for more complex and/or larger projects, eg quest systems, own dialogues, achievements and etc.
Sorry if you've done it in other videos but I think you should mention parameterized queries (you don't want to get a Bobby table incident) and transactions. For example if you make a crafting system it would be better to wrap the loss of materials and inserting new item inside a transaction so you don't get a way to duplicate things if the player crashes the game at the right moment.
for any wondering, i just tested. you can just build your database in the db browser, no need to construct it in godot (assuming doing something like an item db, that doesn't need to be written during play)
You def can, however in my exp I find its bad in practice. Most of the time its fine but you should always have your code check to see if the db exists before trying to hit it. It can help with dealing with random in production errors.
when would you want to use a SQLight data base vs some other storage? is it faster for X data, smaller for Y data, easier to use with Z data, able to handle huge amounts of A data, really easy to store B data remotely, really useful with C data, perhaps D data can be encrypted in a easy way, E data has low overhead storage, or something else with F data. I guess you address my question at 24:13 data normalization, I would like to know more about selecting the best storage from available options. if you do make the data base video perhaps you could have a section on it, but don't go out of your way too much.
I actually was going to talk about this but didn't, I thought it would take away from the tutorial.... (though I realize now I should have). I'll create an additional tutorial to explain it further. To answer your question though: SQL excels in managing complex data with interconnected elements. Imagine a scenario where a person works for a company, and this company has several employees, including that person. In SQL, this would be organized into three tables: person, company, and employees. The company table house company informaiton that would be linked to employees that house employee data like salary position etc, and these employees are also llinked to the person table which houses name address etc. The reason this is nice is it alows you to segment your data in a nice logical format that you can scale. When managing this kind of data with JSON, you would need to load the entire file and parse the data, which can be painful to handle. Imagine having 500 employees do you store all of there info in a single json or multiple files then you have to worry about directories and storting.. Also SQL is generally faster for more complex operations. It's not the best choice for simple tasks like storing basic save data. However, for more complex data involving save data, weapon data, stats, and level information, SQL is significantly more efficient. A huge advantage of SQL is the ability to read and write data simultaneously, which becomes very important as your data volume grows. I hope my ramblings make some sense let me know if you have more questions.
So, in my game player data will be stored in the database, as will inventory items and their characteristics, and enemy data (different enemy types have varies characteristics)... I want them all to be connectable in game via the database... how would you approach this? Would love a follow up video on databases.
Are the args in select_row(), update_row(), insert_row() sanitized and using prepared statement to avoid sql injections? I didn't see it mentioned in the document.
Another easy way to do this is with a SQLite nuget with C# in visual studio you just have to connect your godot project with VS. You can pretty much set it up in 2 mins. Even if you prefer gdscripts you can still just make one c# script for your database and make everything else in gdscript.
33:43 The code right here is broken but functional, you iterate over every column and create an image from the data, including the name and score. It will break once you add another column.
I'm not sure I'm following, I just added another column and it's fine. Query result will return a list of objects and our code iterates though each object not column We are picking which column we want to pull our data from by doing I.picture which returns the picture.
The reason DB Browser doesn't get installed into your program menu is because you told it not to. At 10:33 the installer asks if you want to add shortcuts to your Desktop or your Program Menu and you left both boxes unchecked. Admittedly a bit of a weird default but, you know, this is why you RTFM. =)
Does someone know how to insert an array of ImageTextures into my database? When setting a blob to an Array it just saves the directory of the images and not the image files right?
Great tutorial! Is it possible to store sounds, like mp3 as a blob and play them in godot as well? If yes, could You provide additional info on how to do it? Additional question: isnt just better to store link to image and have image inside folder, instead to store the image itself into database?
can we export the app with sqlite and run it on an android device? i'm having trouble while exporting sqlite, could you make a video or give instructions on it?
It's really cool how fast you debug using breakpoints, something I kind of avoid cause I don't understand well how it works, do you have any tutorial about debugging?? thanks for your awesome content...
Do you know to get the id of the row that was last inserted? I tried scope_identity and _last_insert_rowid + a bunch of other ways I thought could maybe work but nothing does. I don’t know if I’m just formatting them wrong or if they aren’t supported.
Iam working on a project Vegetable calculator ,how to save my all data and set data when load() ! . I crated a main scene and instance button and delete .the instance scene contains a script for calculate amount and has 3 lineedit and labe to display amount . how to load datat through instance and set instance.name and instance.rate through database ?..............
I would look at my SQLite entity framework tutorial. What I would do is make model objects the instance scene. From there I would set up my single light database with those model objects using entity framework and then put all the data inside of there and when I instance my scene is load the data. You could in theory save your node directly using Godot's binary writer but you will get a lot of extra data saved like position rotation, things like that so it's not super efficient but it's not a horrible way to go
Thank you excellent tutorial, I have question now after you export release and you run the game on other computer we'll have problem the game will not access to the data becaused SQLite is not installed, how to let godot including SQLite dll file?
For me I didnt hav ethis problem but in your export settings under the last tab you can include directories and that should work. If not just copy the DLL to the main folder of your export and it should just work.
Correct that's because when you delete data from a database it doesn't technically go away. What it does is it says that area is no longer occupied but it still says the same size so when you insert data it should reuse that empty space. If you want you can run a pragma to reduce the file size I'll have to look for which one it is
@@ArabGameDev The plugin that Godot has does not support that as far as I know. I do know the c# plugin does support it however. One way around it is to create a key in your code and to encrypt your data before you insert it and after you select it.
For someone wanting to export a game to iOS, test exporting before you get too far into this. Last I checked (about 1 month ago) Godot 4 exports to iOS don't work with SQLite on my setup.
I know sqlite itself works on IOS ive used it for work projects but I think the plugin itself doesnt support it or something with how GD extension works.
@@FinePointCGI Yes, I was using SQLite successfully in Godot 3.5, but couldn't get it going in Godot 4.1. I ended up ripping SQLite out so I can get my app migrated to Godot 4. (Perhaps whatever problem I encountered has been resolved now, I don't have much reason to revisit the decision to pull it out of my code at the moment)
@@bissash05 I rewrote my code to load/save a Dictionary to/from JSON, and haven't needed to move back to sqlite. So I don't know if the situation has changed.
M Y B O Y M O C H I Really useful to use as a guide to get started with the addon and as an overview when considering if it will be useful for a specific project. Great stuff!
I somehow didn't expect an SQLite integration being that easy! Awesome. As a web developer for a living an actual database is definitely an alternative to using resources in Godot (which I somehow prefer over JSON files). Thank you for your efforts of creating such more in-depth videos (unlike others who explain how to add a node to the scene tree and nothing else which doesn't help anyone at all).
Once you realize your multiplayer RPG can only handle so many networked objects (players and mobs) so now you use real world solution by using docker so you can spin up instances of your map and they all need to connect to the same database without overloading your database connection so you have to use cockroachdb so you can have multiple instances of the database. Disclaimer: Not all games are the same.
Error : No suitable library found for GDExtension: res://addons/godot-sqlite/gdsqlite.gdextension. Possible feature flags for your platform: mobile, android, etc2, astc, arm32, arm64, template, debug, template_debug, single the res://addons/godot-sqlite/gdsqlite.gdextension dose not have compile architecture.os !. LOCATION : "res://addons/godot-sqlite/bin/" PATH : libgdsqlite.android.template_debug.arm64.so It ONLY SUPPORTS amrabi-a8v architecture into APK , If i use "armeabi-v7a", "x86", "x86_64" then the APK CRASH even I use GRADLE into APK OR ABB ANY SOLUTION !.................. HOW TO FIX ?.......................
awesome plugin, although i would not use the wrapper functions that takes in dicts, sql is easy to learn and i think i prefer the control of forming my of queries.
I have no idea how you made SQL seem approachable but thank you so much! Forgive me if this is a dumb question, but would it be straightforward to make the database an online database so different players could share it at once?
ERROR : armeabi-v7a , x86, x86_64 " .os " in bin not there , only " arm64-v8a " can export to APK or ABB in SQLite , Is there any solution ?.... HELP !....
No suitable library found for GDExtension: res://addons/godot-sqlite/gdsqlite.gdextension. Possible feature flags for your platform: mobile, android, etc2, astc, arm32, arm64, template, debug, template_debug, single
thank you so much for this tutorial everything is perfect and working just like what you uploaded 2yrs ago is really helpful for someone who used to be in making queries sql
can I use this as an alternate of using Resource? I mean will my game runs slower if I directly assign my variable with the queries result from my database?
SQLite is amazing for more complicated data. IF you ever need to have subsets of data its very useful so think of it like this i have 1000 items each one is a json file managing that is painful but if its all in one db its simpler to work with. If you put them all in one file then if you only want one item you need to load the entire file then pick the one you want but with sqlite you can just select the one you need based off of id or name.
Amazing video, very informative and helpful. Thanks for your contribution! One thing that I think is missing (I'm searching for the answer now with little success) is how to access the database when it is stored remotely (on a web server). Works great when the database is stored locally, but I think a lot of people want online functionality! EDIT: also, it doesn't appear to work locally when exporting to android. open_db() fails to return anything when running the android build :( any help would be appreciated!
I agree sqlite is designed mostly for local only access you could use SQLite if you wanted to you could use it with an API and use it as your main database however that would not scale at all.
This is awesome. I was thinking about exporting it as JSON, but I'm considering storing the data with SQLite! P.S. You are the best Godot Engine UA-camr I know. I started developing the game in earnest in June, and started watching your videos in October. I've learned more since then than I ever did before. Sincerely, you are the Best of Best tutor.
first 😁
THANK YOU! I can't believe it took me so long to integrate SQL databases into my workflow. It's so simple it feels like I was a caveman just mucking about in the dirt before. lol
Yes of course want a database tutorial, trying to learn it for resume
This was a life saver for my current project. I was banging my head in dealing with loads of people in a world that i dont need to actively show but handle nonetheless and keep persistent over sessions. This just solved all my issues!
I would like to ask for some guidance on how to make this database accessible from different devices. My ideal scenario would be to have a mobile app where the database is online and every app can insert/remove data. I apologize if this is a basic question, but I am new to this topic. Thank you for the awsome video and your help.
Thank you for this. Edit: SQLite in user:/ seems the way to go, handling data for more complex and/or larger projects, eg quest systems, own dialogues, achievements and etc.
Very nice to know! Seems to be a good way to handle complexity better.
Sorry if you've done it in other videos but I think you should mention parameterized queries (you don't want to get a Bobby table incident) and transactions. For example if you make a crafting system it would be better to wrap the loss of materials and inserting new item inside a transaction so you don't get a way to duplicate things if the player crashes the game at the right moment.
Yeah it's one of my main misses in this tutorial... I should have brought it up but I never did
incredible, comprehensive tutorial. exactly what i was looking for.
for any wondering, i just tested. you can just build your database in the db browser, no need to construct it in godot (assuming doing something like an item db, that doesn't need to be written during play)
You def can, however in my exp I find its bad in practice. Most of the time its fine but you should always have your code check to see if the db exists before trying to hit it. It can help with dealing with random in production errors.
Thank you, this is a great video and is helping me with a school project!
Thank you this helped a ton.
Thank you SO much for this tutorial
when would you want to use a SQLight data base vs some other storage? is it faster for X data, smaller for Y data, easier to use with Z data, able to handle huge amounts of A data, really easy to store B data remotely, really useful with C data, perhaps D data can be encrypted in a easy way, E data has low overhead storage, or something else with F data. I guess you address my question at 24:13 data normalization, I would like to know more about selecting the best storage from available options. if you do make the data base video perhaps you could have a section on it, but don't go out of your way too much.
I actually was going to talk about this but didn't, I thought it would take away from the tutorial.... (though I realize now I should have). I'll create an additional tutorial to explain it further. To answer your question though:
SQL excels in managing complex data with interconnected elements. Imagine a scenario where a person works for a company, and this company has several employees, including that person. In SQL, this would be organized into three tables: person, company, and employees. The company table house company informaiton that would be linked to employees that house employee data like salary position etc, and these employees are also llinked to the person table which houses name address etc. The reason this is nice is it alows you to segment your data in a nice logical format that you can scale.
When managing this kind of data with JSON, you would need to load the entire file and parse the data, which can be painful to handle. Imagine having 500 employees do you store all of there info in a single json or multiple files then you have to worry about directories and storting..
Also SQL is generally faster for more complex operations. It's not the best choice for simple tasks like storing basic save data. However, for more complex data involving save data, weapon data, stats, and level information, SQL is significantly more efficient. A huge advantage of SQL is the ability to read and write data simultaneously, which becomes very important as your data volume grows.
I hope my ramblings make some sense let me know if you have more questions.
So, in my game player data will be stored in the database, as will inventory items and their characteristics, and enemy data (different enemy types have varies characteristics)... I want them all to be connectable in game via the database... how would you approach this? Would love a follow up video on databases.
i get SQL error: out of memory when inserting data , what should i do ?
Edit : you have to add open_db() before it
Are the args in select_row(), update_row(), insert_row() sanitized and using prepared statement to avoid sql injections? I didn't see it mentioned in the document.
Another easy way to do this is with a SQLite nuget with C# in visual studio you just have to connect your godot project with VS. You can pretty much set it up in 2 mins. Even if you prefer gdscripts you can still just make one c# script for your database and make everything else in gdscript.
This is my general approach for things, but doesn't work if you're building for web since C# is currently has no web support in 4.x
33:43 The code right here is broken but functional, you iterate over every column and create an image from the data, including the name and score. It will break once you add another column.
I'm not sure I'm following, I just added another column and it's fine. Query result will return a list of objects and our code iterates though each object not column
We are picking which column we want to pull our data from by doing I.picture which returns the picture.
@@FinePointCGI I see now, I was thrown off because I'm not used to the soft typing of gdscript. You're right.
The reason DB Browser doesn't get installed into your program menu is because you told it not to. At 10:33 the installer asks if you want to add shortcuts to your Desktop or your Program Menu and you left both boxes unchecked. Admittedly a bit of a weird default but, you know, this is why you RTFM. =)
Does someone know how to insert an array of ImageTextures into my database? When setting a blob to an Array it just saves the directory of the images and not the image files right?
Great tutorial!
Is it possible to store sounds, like mp3 as a blob and play them in godot as well? If yes, could You provide additional info on how to do it?
Additional question: isnt just better to store link to image and have image inside folder, instead to store the image itself into database?
actually it says for html5 3.3+ so anything from 3.3 and higher is supported !!! that includes godot 4
That's what I was about to say
can we export the app with sqlite and run it on an android device? i'm having trouble while exporting sqlite, could you make a video or give instructions on it?
In Godot's assetlib I didn't find godot-sqlite! Postgree only appeared, can you integrate SQL without installing it through assetlib?
yes you can dowload it directly from the github
github.com/2shady4u/godot-sqlite/releases/tag/v4.4
@@FinePointCGI Okay, I'll try! thanks
If i want to insert a data into my database table it says as a error "SQL error: database is locked" can anyone help me? xD
NVM I found the reason why... It was because it was opened in DB Browser xDDD
It's really cool how fast you debug using breakpoints, something I kind of avoid cause I don't understand well how it works, do you have any tutorial about debugging?? thanks for your awesome content...
Do you know to get the id of the row that was last inserted? I tried scope_identity and _last_insert_rowid + a bunch of other ways I thought could maybe work but nothing does. I don’t know if I’m just formatting them wrong or if they aren’t supported.
The same proyect with program language c# or not
Iam working on a project Vegetable calculator ,how to save my all data and set data when load() ! . I crated a main scene and instance button and delete .the instance scene contains a script for calculate amount and has 3 lineedit and labe to display amount . how to load datat through instance and set instance.name and instance.rate through database ?..............
Or is their any way to save my entire node with instanced scene's ?..
I would look at my SQLite entity framework tutorial. What I would do is make model objects the instance scene. From there I would set up my single light database with those model objects using entity framework and then put all the data inside of there and when I instance my scene is load the data.
You could in theory save your node directly using Godot's binary writer but you will get a lot of extra data saved like position rotation, things like that so it's not super efficient but it's not a horrible way to go
Thank you excellent tutorial,
I have question now after you export release and you run the game on other computer we'll have problem the game will not access to the data becaused SQLite is not installed, how to let godot including SQLite dll file?
For me I didnt hav ethis problem but in your export settings under the last tab you can include directories and that should work. If not just copy the DLL to the main folder of your export and it should just work.
Tnx very useful tutorial
Can u make a tutorial about new Android plugin version 2 in Godot 4.2
I want to I just need to learn how it works
@@FinePointCGI thanks man u are the best
What about security? Can we encrypt the database? Or put credentials?
The addon does not support it but sqlite does so hopefully the team will add it.
hi
i insert 1000 rows and the db file is 50kb then i deleted all rows and the file is still 50kb ??
Correct that's because when you delete data from a database it doesn't technically go away. What it does is it says that area is no longer occupied but it still says the same size so when you insert data it should reuse that empty space. If you want you can run a pragma to reduce the file size I'll have to look for which one it is
@@FinePointCGI does sqlite has encryption with godot
@@ArabGameDev The plugin that Godot has does not support that as far as I know. I do know the c# plugin does support it however.
One way around it is to create a key in your code and to encrypt your data before you insert it and after you select it.
udpated PostgrSQL godot 4.2 pls
For someone wanting to export a game to iOS, test exporting before you get too far into this. Last I checked (about 1 month ago) Godot 4 exports to iOS don't work with SQLite on my setup.
I know sqlite itself works on IOS ive used it for work projects but I think the plugin itself doesnt support it or something with how GD extension works.
@@FinePointCGI Yes, I was using SQLite successfully in Godot 3.5, but couldn't get it going in Godot 4.1. I ended up ripping SQLite out so I can get my app migrated to Godot 4.
(Perhaps whatever problem I encountered has been resolved now, I don't have much reason to revisit the decision to pull it out of my code at the moment)
@@jay.rhoden Do you know if something changed with Godot 4.2.1?
@@bissash05 I rewrote my code to load/save a Dictionary to/from JSON, and haven't needed to move back to sqlite. So I don't know if the situation has changed.
M Y
B O Y
M O C H I
Really useful to use as a guide to get started with the addon and as an overview when considering if it will be useful for a specific project. Great stuff!
!....
I somehow didn't expect an SQLite integration being that easy! Awesome.
As a web developer for a living an actual database is definitely an alternative to using resources in Godot (which I somehow prefer over JSON files). Thank you for your efforts of creating such more in-depth videos (unlike others who explain how to add a node to the scene tree and nothing else which doesn't help anyone at all).
Once you realize your multiplayer RPG can only handle so many networked objects (players and mobs) so now you use real world solution by using docker so you can spin up instances of your map and they all need to connect to the same database without overloading your database connection so you have to use cockroachdb so you can have multiple instances of the database. Disclaimer: Not all games are the same.
This is fantastic! I've been wishing I could use a database in Godot, and this is exactly what I wanted. Great video!
+1 for a crazy database tutorial! Fantastic work!
Error : No suitable library found for GDExtension: res://addons/godot-sqlite/gdsqlite.gdextension. Possible feature flags for your platform: mobile, android, etc2, astc, arm32, arm64, template, debug, template_debug, single
the res://addons/godot-sqlite/gdsqlite.gdextension dose not have compile architecture.os !.
LOCATION :
"res://addons/godot-sqlite/bin/"
PATH : libgdsqlite.android.template_debug.arm64.so
It ONLY SUPPORTS amrabi-a8v architecture into APK ,
If i use "armeabi-v7a", "x86", "x86_64" then the APK CRASH even I use GRADLE into APK OR ABB
ANY SOLUTION !..................
HOW TO FIX ?.......................
What happen when you rollout a new version of the game with a updated db schema? Is there a way to run migrations on the users' device?
awesome plugin, although i would not use the wrapper functions that takes in dicts, sql is easy to learn and i think i prefer the control of forming my of queries.
I can't find "Godot Sqlite" in AssetLib.
Do I have to copy something downloaded somewhere so that I can find it?
Try SQLite and see if it comes up. You can also head out to their git
github.com/2shady4u/godot-sqlite
@@FinePointCGI Thank you
Hi, try download latest version of engine. I have the same error and this fix it.
I have no idea how you made SQL seem approachable but thank you so much! Forgive me if this is a dumb question, but would it be straightforward to make the database an online database so different players could share it at once?
This guy is a beast!
This is a massive game changer.
aAAAARRRRGGGHHHH!!!! It's SQL!!! NOT sequel!!!!!!!!!!!!!!!!
And how about packing the database with the .exe ?
Thanks very helpful video
My name is John'truncate user
ERROR : armeabi-v7a , x86, x86_64 " .os " in bin not there , only " arm64-v8a " can export to APK or ABB in SQLite , Is there any solution ?.... HELP !....
Me to
No suitable library found for GDExtension: res://addons/godot-sqlite/gdsqlite.gdextension. Possible feature flags for your platform: mobile, android, etc2, astc, arm32, arm64, template, debug, template_debug, single
isn't the html5 require +3.3+ the "+" means 3.3 or higher?
3.3 and higher I believe however I'm not fully sure
thank you so much for this tutorial everything is perfect and working just like what you uploaded 2yrs ago is really helpful for someone who used to be in making queries sql
can I use this as an alternate of using Resource? I mean will my game runs slower if I directly assign my variable with the queries result from my database?
It shouldnt slow down much if at all. The idea is to allow you to control your data better and able to segment your data.
@@FinePointCGI Appreciate it, this is a great video thank you for sharing!
Is it possible to parse the database into a dictionary?
nevermind i made my own
What are the case usages for using SQLite?
SQLite is amazing for more complicated data. IF you ever need to have subsets of data its very useful so think of it like this
i have 1000 items each one is a json file managing that is painful but if its all in one db its simpler to work with.
If you put them all in one file then if you only want one item you need to load the entire file then pick the one you want but with sqlite you can just select the one you need based off of id or name.
I have this error in the editor -> "GDScript bug: Native class "SQLite" not found." Anyone experiencing this like me?
Thanks for the tutorial. This will be very helpful!
Awesome vid! Thank you
Amazing video, very informative and helpful. Thanks for your contribution! One thing that I think is missing (I'm searching for the answer now with little success) is how to access the database when it is stored remotely (on a web server). Works great when the database is stored locally, but I think a lot of people want online functionality!
EDIT: also, it doesn't appear to work locally when exporting to android. open_db() fails to return anything when running the android build :( any help would be appreciated!
I think sqlite is not meant for that usecase. I believe postgresql would be better.... But there are plenty of other dbs as well ofcourse
I agree sqlite is designed mostly for local only access you could use SQLite if you wanted to you could use it with an API and use it as your main database however that would not scale at all.
Hello, big thanks for the tutorial, I guess using sqlite is for clientside only ? And how can we prevent our players to change the data on local ?
You can encrypt your database to prevent that. I do not believe the addon supports it though
Thx for your answer^^
This is awesome. I was thinking about exporting it as JSON, but I'm considering storing the data with SQLite!
P.S.
You are the best Godot Engine UA-camr I know. I started developing the game in earnest in June, and started watching your videos in October. I've learned more since then than I ever did before.
Sincerely, you are the Best of Best tutor.