Closed rslonake closed 3 months ago
This is the line giving me an error.. database.update_rows("player_inventory", "row_number = int(row_number) " , {count = updated_count})
How do I pass back to the database the integer value of the row_number variable?
So, I was able to solve this on... here is the update_rows line that works...
database.update_rows("player_inventory", "player_id = '" + $PlayerID.text + "' AND item_id = '" + $InventoryID.text + "'" , {count = updated_count})
Hope this helps someone (or me in the future)
I need to update a specific row based on the row_number, inventory count (quanity from inventory), and some amount to be added or subtracted... I am using TextEdit bixes to enter a specific player_id and item_id for the query...
I am able to identify the appropriate row and count from the inventory basedon the query...
var query_results = database.select_rows("player_inventory", "player_id = '" + $PlayerID.text + "' AND item_id = '" + $InventoryID.text + "'", ["row_number, count"])
I then set the row_number as an integer variable and the count as a seperate interger variable
I then modify the count using a formula... I print out everything it looks correct...
BUT, when I write the line to update_rows I get errors or the wrong stuff gets updated... here are some examples with explanations
this works BUT updates ALL rows in the table with the correct new 'count' value
database.update_rows("player_inventory", "row_number = row_number " , {"count" : updated_count})
this updates the correct row (10) with the correct new 'count' value - but this works because I manually specify the row
database.update_rows("player_inventory", "row_number = 10 " , {"count" : updated_count})
this gives me a "Invalid operands 'String' and 'int' in opertator '+' error.
database.update_rows("player_inventory", "row_number = '" + row_number + "'", {count = updated_count})
this runs but I get a "SQL error: no such function: int" back and nothing gets updated in the database
database.update_rows("player_inventory", "row_number = int(row_number) " , {count = updated_count})
If it helps, here is the entire script...
extends Control
var database : SQLite
Called when the node enters the scene tree for the first time.
func _ready(): database = SQLite.new() database.path="res://Database/angler_database.db"
Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta): pass
func _on_update_data_button_down(): database.open_db()
And here is the output when I run this... Opened database successfully (E:/Gogot_practice_project/Database/angler_database.db) [{ "row_number": 94, "count": 12 }] the row to update is 94 the database amount is 12 the amount of change is -5 the updated_count is 7 --> SQL error: no such function: int