Hello,

I'm new to godot, i started a project with godot 4 beta 5 and i need a dedicated server that communicate with a mysql database. (XAMPP for the time being)

After some research, correct me if i'm wrong but it seems that the ENet wrapper doesn't have a mysql interface. I saw that there are some modules here and there but it requires to recompile the godot engine or something and wish to avoid that.

Since i don't need the godot client to interact with the database, i have in mind to simply code a c++ server using ENet with SQLite for example.

Would there be a problem doing so?
Any other languages or tools that would be more practical?
Any suggestions are welcome in case there would be a better solution.

thx

    noals You could take a look at this MySQL add-on or this MariaDB add-on. I would suggest not using Godot 4.0 right now since it has not been finalized, i.e. it's still in beta and these add-ons may not work that well with it.

      Ertain
      Hi, thx for the answer.

      Godot 4 beta is a bit glitchy but i don't want to have to convert my project later on, my game will be for android, i think Godot 4 will help with that, right?

      I will read about recompiling Godot, i hate compiling so much, i'm already struggling with ENet and SQLitecpp anyway...
      How come coding is more easy than building...><

        No fear. Building Godot with Scons is straightforward and you don't have to know much about the build system Scons to successfully build Godot. There's a how-to page in the documentation that describes it.

        Building other open source projects often involves cmake or the underlying make, so it may be worthwhile to look up a tutorial or two on those.

        Coding easier than building ? If you say so :-)

          noals my game will be for android, i think Godot 4 will help with that, right?

          Not sure what you mean by that. Android export templates already exist for Godot 3.

            Pixophir
            I never heard about SCons before Godot actually, i will read about it.
            https://docs.godotengine.org/en/stable/development/compiling/introduction_to_the_buildsystem.html
            I'm still not sure if making a c++ server woudn't be the best solution but i'm also worrying that the ENet version of Godot (which is?) wouldn't be compatible with the last one or something.
            I used cmake before for some other projects but here i'm just on my laptop in another country so Windows it is for the time being. thx

            Megalomaniak
            I think i read about some issues about it here and there on the net that Godot 4 would fix but i cannot be more precise, i don't remember. I spent a lot of time reading all kind of stuff before starting my project to choose the best tools for my need, i ended up choosing Godot anyway, i just hope for the Godot 4 release as soon as possible. There is still a lot of time before i will try my stuff on Android anyway. thx

              noals I'm still not sure if making a c++ server woudn't be the best solution but i'm also worrying that the ENet version of Godot (which is?) wouldn't be compatible with the last one or something.

              That part I don't understand.

              noals I never heard about SCons before Godot actually, i will read about it.

              You just need to follow the "Compiling for Windows" part.
              https://docs.godotengine.org/en/stable/development/compiling/compiling_for_windows.html
              Compilation may take some time on a laptop.

                Pixophir
                yeah, it's compiling, i don't know how much time it will take, i should have add the sql module before trying ^^;

                I use godot to make the client but for the server, it could simply be a c++ console application that include ENet and SQLitecpp. From the ENet version used in godot and the last ENet version, there is some changes i suppose and if for example my server cannot recognize the packet sent by the client because of those changes in the library, it could be a mess. Maybe i'm just worrying too much, i'm no expert, i just code from time to time.

                It's ok, it doesn't take too much time to compile (00:32:11:686 ^^) and everything seems fine.

                But what about modules?
                Should i add C++ MySQL Connector Library and Boost somehow with scons or in the godot-master files or scons just add the module automaticaly with the tutorial's command line?
                "scons custom_modules="../modules,/abs/path/to/modules,~/src/godot_modules""
                https://github.com/Malkverbena/mysql

                can someone explain me the process? I don't think Malkverbena use scons for his modules.

                  I know nothing about MySQL, I am sorry.

                  You don't need Scons for the upcoming Godot Extensions (the successor of GDNative in Godot 4). Documentation isn't yet complete, but there's an example of how to do it (that actually worked under beta 4). But in the end you just compile your project independently from the Godot engine (well, you need the headers of course).

                  I find Godot 4 beta too buggy, and there's still the danger of breaking changes, to actually do productive stuff with it atm and on that level.

                    So you can have the server with MySQL using standard web tools. Godot can communicate over HTTP, so you could use PHP, for example, with MySQL. You can also communicate with sockets, but this is low level and not needed. Depending on what you are doing, you can use Godot as the server on a Linux machine. This is useful for multiplayer games. But for straight database access, using HTTP will be the easiest.

                    https://docs.godotengine.org/en/stable/tutorials/networking/http_request_class.html

                      Pixophir
                      Ha ok thx https://godotengine.org/article/introducing-gd-extensions
                      Until now, i just had a texture scaling glitch kinda. I didn't do much yet but my project isn't retro-compatible already, i will see how it goes.

                      cybereality
                      Yes, i just need the server to access the data base. I'm not really familiar with HTTP request or PHP, i will read more about it thx.

                      edit: just found this https://www.raghwendra.com/blog/how-to-connect-html-to-database-with-mysql-using-php-example/

                      If you want to run Godot on a headless server (Linux server) you can use C++. If you already have C++ code, you can turn it into a module (Godot add-on or extension). It is called GDNative. However, I still think it will be easier with PHP.

                        cybereality
                        It shouldn't be that hard with C++, you have the little library that allow you to access the db (i'm looking into other options atm SOCI, LiteSQL, qtl,...) so you get the infos you need, pass it into a string and then send it to the client with ENet. I did it before but i'm a bit lost after a few years without prog, it's like the easy-to-use libraries i was using before disappeared magically so the net can offer me all kind of shit-to-link-and-compile -without-tutos libraries wth? lol

                        The problem i see with HTTP request/PHP is that it need an intermediate right?
                        Server->PHP->Database
                        while i just need to do Server->Database.

                        I'm still looking into things, i will post again later if i make any progress, find a fitting solution for me, if i have more questions or whatever.

                        Thanks for all your answers.

                        What exactly is the use case? Is this a game or some sort of app? Do you have a client and server already in place (meaning there are two apps)? I assume the client must be in Godot, but what is the server running on?

                        @cybereality : I understand they have a XAMPP stack running against which to perform database queries. So I reckon both versions would work from a Godot pov, that is performing http-requests against the patchy server, or with C++ and the database's API.

                        The first would then be your suggestion to script https requests in Godot without doing a module or extension, the second making a C++ module (Godot 3.x) or extension (Godot 4.y).

                        Hope that wasn't totally nonsensical :-)

                        Yes, it's like that.
                        I have a XAMPP server with a mysql database.
                        For the time being the server will be a windows console app but yeah it could be on linux later.
                        I didn't do much yet, there are things that i'm still designing so it's more about having the best tools that will let me do anything i want the simplest way possible.

                        XAMPP is a PHP environment, so it would make sense to use that.

                          cybereality
                          I don't know, i'm still trying different tools, i will maybe use postgresql but it's like, for the past few years, the number of dependencies for all libraries multiplied by 10 and even if you get to compile, it's possible that you have some .dll missing for a simple console app that say "hello world!"... ><

                          to be continued....

                          Let me ask, what are you actually trying to achieve ?

                          Maybe there's an easier way than all that heap of stuff.