Search code examples
c#postgresqlunity-game-engineherokuheroku-postgres

What should i do to connect and make queries to Heroku PostgreSQL from Unity/C#/vs code?


How to connect to Postgres db with Unity/C#? How to execute queries? I have Postgres db on Heroku server (not localhost) and was able to work with it via python and psycopg2 but now i use Unity. I have all db credentials. Just do not know which library to use and how to install it. I use Ubuntu and VS Code. I installed Nuget and Npgsql via Nuget but its classes are not visible in VS Code for some reason


Solution

  • I found Npgsql.dll on dllme.com. I put it to Plugins folder that I created in Assets in Unity. That gave me some errors: Npgsql needed some dlls. I followed them and found those dlls on dllme.com and put them to Plugins also. And continued until there will be no errors. And it works now on my Ubuntu with local PostgreSQL DB. I have 5 dlls in Plugins: Npgsql, System.Buffers, System.Memory, System.Runtime.CompilerServices.Unsafe, System.Threading.Tasks.Extensions