![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Görf |
Hey,
I consider to change from unity to godot.
My next project needs a small dedicated server, which settles on a postgreSQL - database (it is my main-database, which I can manage central across all project (dumps, administration,…).
I searched for postgreSQL-Support but the last answer I find was a “no, not yet” from 2018. Is there any update of this answer?
Is it possible to include e.g. Npgsql in a godot-project?
I am sorry for such a “beginner”-question. I read a few comparison between unity and godot and with some experience in my mind (love2d, .NET) I want to switch - but with my favorite database for server
Thanks for reading and I wish you a great sunday.
From this i guess you can include c# libraries, so it should work, but i’ll let someone who knows for sure answer.
RazorSh4rk | 2020-05-24 19:01
First, I had to install the mono-version for c#-support.
My test-project throw out a build-error, that the mbuild couldn’t find the .Net-Framework, but it was installed.
After installing the whole Visual-Studio-Package or editing the csproj I got the same error.
Before giving up for the day I decided to create a brand new godot-project. This one I could build.
So I created the test project with a moving player.
After that I installe VS-code and there I installed the package manager.
With STRG+P and add package I added Npgsql.
VS-Code added the lines:
to my csproj - File.
Now I run dotnet restore in VS-code.
Now I run nuget restore in VS-Code. Sadly, this didn’t worked and I can’t figure out, why.
I removed the lines in csproj-files.
Now I try to open a test-database and write a line in a table for test-reasons:
public override void _Ready(){
GD.Print("test");
_screenSize = GetViewport().Size;
string cs = "Host=kandula.db.elephantsql.com;Username=hidden_user;Password=hidden_pw;Database=hidden_db";
con = new NpgsqlConnection(cs);
try
{
con.Open();
NpgsqlCommand cmd = new NpgsqlCommand("INSERT INTO public.cars (name, price) VALUES (@n, @p)", con);
cmd.Parameters.AddWithValue("n", "bla");
cmd.Parameters.AddWithValue("p", 123);
//cmd.Prepare();
cmd.ExecuteNonQuery();
}
catch
{
GD.Print("catch");
return;
}}
First, I don’t know why it doesn’t work with VS-Studio. Also, I don’t know how to handle exceptions in godot.
But: Awesome, it works, the values are in the database. I think I give godot and myself a try and look for some basic tutorials.
Thanks for your help!
Görf | 2020-05-25 17:12