sqlite - Can't access data with variable

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mister_why

Hello,

I’m making a game based on vocabulary.

For that I was thinking about using sqlite, so I download the module from : https://github.com/2shady4u.

So far so good I can explore the data base, but when I want to make a request (a query) with variable, then I can’t go further :confused:

It’s this line of my code that didn’t work (I don’t have any issue but no result ^^ :

	db.query("SELECT * FROM words WHERE id = ?",[test])

Here is my code :

extends Node


const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns")
#const SQLite = preload("res://module/sqlite")

var db;

var db_name = "res://bdd.db"

var result

#var ligne

func _ready():

    db = SQLite.new();

    db.path = db_name

    db.open_db(db_name)

    db.query("SELECT * FROM words WHERE trials = 0 ORDER BY RANDOM() LIMIT 1;")

    var ligne = db.query_result[0]["id"]

    print("ligne : ")
    print(ligne)

    for i in db.query_result:
	    print(i.id)
	    print(i.FR)
	    print(i.NL)
	    print(i.TRIALS)
	



	    db.query("UPDATE words SET trials = 1 WHERE id = ?",i.id)
	
	    print("updated")
	

    print("a nouveau ligne")
    print(ligne)

    var test = "3";

    db.query("SELECT * FROM words WHERE id = ?",[test])

    print("selected")

    for j in db.query_result:
	    print(j)
	

	
    db.close_db()

Thanks a lot !

Take care of your self

PS : I also have seen that Godot have a built in sqlite module but I can’t make it work :confused:

godot sqlite built in module