Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access db after setting to read-only mode via gdscript #179

Open
OSeraph opened this issue Jul 10, 2024 · 5 comments
Open

Cannot access db after setting to read-only mode via gdscript #179

OSeraph opened this issue Jul 10, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@OSeraph
Copy link

OSeraph commented Jul 10, 2024

Environment:

  • OS: Windows
  • Godot version: 4.2
  • godot-sqlite version: 4.3

Issue description:
Given that I have set the db to read_only mode before opening the db and export the project with or without the embedded pck option selected when a query is performed by the exported exe OR in the editor that would normally be successful if the db was opened in r/w mode AND while the game was running via the editor the result is the following

   --> SQL error: unable to open database file
   --> SQL error: unable to open database file

Steps to reproduce:

  • Create database file and load with data
  • set to read only mode before opening in gdscript
  • run any query that would normally succeed if opened in r/w mode
  • export project
  • run resulting exe
  • observe

Minimal reproduction project:

class_name Database
extends Node

var db 
var db_path = "res://db/database" 

func _ready():
	if not db:
		var _db = SQLite.new()
		_db.read_only = true
		_db.path = db_path
		db = _db
	open()

func open() -> void:
	db.open_db()
	var tables = list_tables()
	if tables.is_empty():
		Logger.log_info("no tables!!!")
	else:
		for name in tables:
			Logger.log_info(name)
func list_tables():
	db.query("SELECT name FROM sqlite_master WHERE type = 'table';")
        return db.query_result

Additional context
Screenshot (19)

@OSeraph OSeraph added the bug Something isn't working label Jul 10, 2024
@OSeraph
Copy link
Author

OSeraph commented Jul 10, 2024

Want to add some further context.

The res://db directory is included in the export filters so is *.db

@2shady4u
Copy link
Owner

Want to add some further context.

The res://db directory is included in the export filters so is *.db

Hello @OSeraph 😄
Could you give me a screenshot of your export filters?

I have tried out your minimal reproduction project and everything works on my end 😢

I see that your Godot is loading .NET when exporting the project, is this because you are using Godot Engine .NET?
I have never tested the library with Godot Engine .NET.

@OSeraph
Copy link
Author

OSeraph commented Jul 10, 2024

Hello @OSeraph 😄 Could you give me a screenshot of your export filters?

Here are the export filters. FWIW this also happens when I try to access the db in read only mode in the godot editor.
Screenshot 2024-07-10 175547

I see that your Godot is loading .NET when exporting the project, is this because you are using Godot Engine .NET? I have never tested the library with Godot Engine .NET.

I'm using the mono version for Godot 4.2.1 however all of my scripts are in gdscript currently.

@2shady4u
Copy link
Owner

I downloaded the Godot 4.2.1 Mono version and tried with that particular version.
Everything seems to work on my end...

Here's a minimal reproduction project:
test_project_issue_179.zip

Could you test out this project and tell me what happens on your end?

@OSeraph
Copy link
Author

OSeraph commented Jul 16, 2024

@2shady4u Sorry for the late reply just now seeing this I will give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants