PostgreSQLClient
PostgreSQLClient copied to clipboard
Godot 4.0 Alpha
So in 3.0's database.execute would return an array of the data you requested however in 4.0 it returns only an integer, how are we supposed to get the data in 4.0 alpha?
Hello, the entity returned with the "execute" method in the godot4 version is actually an enumeration, the execution error number. To get the result of a request you must wait for a "data_received" signal to be emitted. It carries with it the result of the request.
The postgre client documentation has changed since version 4 of godot. A signal is emitted (request processing time by the backend). This is to prevent the request from blocking the Godot process. An example in the Helloworld.gd file is provided for this version (alpha branch).
seems very counter intuitive and not simple to use
However, this is necessary because the backend takes some time to execute the query before sending the result to the fontend. On the godot3 version the process hangs during this time which leads to friezes of games or game servers. On godot 4 I removed this constraint to avoid this problem. Once you send a request to the backend, you have to wait for a response. This results in waiting for the "data_received" signal to be emitted. Waiting for the result of the query is an unavoidable constraint in client/server applications. A solution to make good use of the client is to send a request to the server, wait for a response from the server and only then execute the next request. you can create a waiting list of Postgres requests to be made if you have a lot of requests to make. when you get a response to a request, you remove that request from the waitlist and move on to the next request.