Question

How to connect Unity to Postgresql database?

Posted January 8, 2022 169 views
PostgreSQLDigitalOcean Managed PostgreSQL DatabaseGaming

I am trying to connect my Unity game to a database I have, however, I’m not sure how I can send a request to it. It’s code that will only be on the server, so I want to write C# code to retrieve data from the database.

I’m also confused as to how I would create new tables. Do I have to use the console the database is assigned to and somehow send SQL commands to create tables that way? I’m not sure because I’m new to this, so any help would be appreciated!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @galactichyperstar,

I’ll recommend you to check the following:

Getting Started with DigitalOcean Managed Databases for PostgreSQL Youtube Video

Just how managed are DigitalOcean’s Managed Databases and how to use them :

https://www.digitalocean.com/blog/just-how-managed-are-digitaloceans-managed-databases/

and the most important one the documentation:

https://docs.digitalocean.com/products/databases/

Basically, you’ll be able to connect to your database and execute commands like CREATE/UPDATE/DROP etc.

  • Hello, I am getting a connection timed out error. I looked through troubleshooting and I already have my PC on the trusted sources list.

    I am using DBeaver on Windows, and I ticked the “Use SSL” button, and for “SSL mode” I set it to “require” but I don’t have the three parameters filled which are “CA Certificate,” “Client Certificate,” and “Client Private Key,” and I’m not sure what to fill in the second two with because the first one I downloaded from the overview page.

    • Hi @galactichyperstar,

      You shouldn’t need the Certificates to enter into your SQL despite it being a Managed Service or not?

      Have you managed to enter other MySQL or SQL instances using DBeaver?

      • I have not tried, this is the only database I need to work on for now.

        I believe I have the correct information in DBeaver. I have tried creating new databases after deleting the old ones, but still the same error. The connection keeps timing out.

        • I believe I figured it out. I cleared the “trusted sources” and now DBeaver let’s me connect. How do I get the right address of my PC so that I can put it in the list? The one that it suggests seems to be incorrect because it won’t connect with that address.