godot-sqlite
godot-sqlite copied to clipboard
database.db isnt in game file
Environment:
- OS: windows
- Godot version: 3.5
- godot-sqlite version: 3.3 Issue description: when i export my game the database.db isnt in the game file itself and its producing problems, it just creates a database.db in the same directory as the game.... any way to fix this? otherwise ppl can see the rows in the database
Steps to reproduce: exporting the project
Minimal reproduction project:
Additional context
Hello @MehLoon,
The answer to your question depends on if you are working with a read-only or with a read-write database. Here are the relevant sections from the documentation:
Read-only databases
If your database serves as static data storage i.e. there's no persistent dynamic data that needs to be saved, then your database is a read-only database. For example, a database that contains a table of monster descriptions and data (experience gained on kill, health points) probably never changes during normal gameplay.
In this case, the database can be packaged in the
*.pck
-file together with all other assets without any hassle.
To enable this behaviour following conditions need to be met:
- The database file has to be added manually to the
include_filter
of yourexport_presets.cfg
-file to package the file on export.- The connection has to be opened in read-only mode by setting the
read_only
variable to True.You can also open databases in read-only mode that are not packaged, albeit under some restrictions such as the fact that the database files have to copied manually to
user://
-folder on mobile platforms (Android & iOS) and for web builds.One important additional constraint for read-only databases is that Godot's implementation of file handling does not allow files to opened in a shareable manner. Basically this means that opening a database connection fails whenever other programs have a read lock on the database file e.g. having the file open in SQLiteStudio for editing purposes. However, multiple simultaneous read-only database connections are allowed.
NOTE: The contents of your PCK file can be verified by using externally available tools as found here.
Read and write databases
NOTE: On mobile platforms (Android & iOS) and for web builds, the method discussed here is not possible and the contents of the
res://data/
-folder have to be copied to theuser://
-folder in its entirety instead (see FAQ above).If your database serves as dynamic data storage i.e. there's persistent dynamic data that needs to be saved during gameplay, then your database is a read and write database. For example, a database that contains a table of character levels and experience dynamically changes whenever the player levels up and/or gains experience.
In this case, the database cannot be packaged in the
*.pck
-file as the contents of this file are static and cannot be dynamically modified during normal operation.All
*.db
-files (and*.json
-files if you choose not to include them in the*.pck
) should preferably be part of the same folder. For example, in the case of the demo-project this is thedata/
-folder. During export this folder has to be copied in its entirety and placed alongside the executable that is created by Godot's export command line utilities.
Hopefully this helps?
Hello @MehLoon,
Is there any update on this issue?
Closed #89 due to inactivity