2shady4u / godot-sqlite

GDExtension wrapper for SQLite (Godot 4.x+)
MIT License
850 stars 76 forks source link

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

Open OSeraph opened 2 weeks ago

OSeraph commented 2 weeks ago

Environment:

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:

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 commented 2 weeks ago

Want to add some further context.

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

2shady4u commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 1 week ago

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