Closed Sythelux closed 8 months ago
GdalBase.ConfigureAll();
instead of Ogr.RegisterAll();
. While executing your example I got an exception on missing "proj.db" which is configured by a call to ConfigureAll
.Here's the modified example.
docker run --name postgis-test -e POSTGRES_PASSWORD=user -e POSTGRES_DB=db -p 5432:5432 -d postgis/postgis
This part I ran in Ubuntu 22.04 with dotnet8
installed:
using MaxRev.Gdal.Core;
using OSGeo.GDAL;
using OSGeo.OGR;
GdalBase.ConfigureAll();
var db = Ogr.Open("PG:dbname=db host=host.docker.internal port=5432 user=postgres password=user", (int)Access.GA_ReadOnly);
Console.WriteLine(db);
if (db != null)
{
for (int i = 0; i < db.GetLayerCount(); i++)
{
var l = db.GetLayerByIndex(i);
Console.WriteLine($"{l.GetName()}: {l.GetSpatialRef().GetName()}");
}
}
else
{
Console.WriteLine("DB not opened");
}
Logs:
no, I haven't read the README. I apologize, but I pretty much started using this package a year ago, because all other packages where a total mess with native bindings and did most stuff in try and error. I adjusted it now.
Thank you for verifying that the issue is not within the package itself. Changing the user to the default postgres user didn't help at all though, but I swapped the docker image I was using kartoza/postgis for some reason. I changed it to postgis/postgis now and it worked. This would've been the last thing to try if you haven't answered. So thank you.
Describe the bug When doing Ogr.Open with a postgres connection string I get a exception saying
connection to server at "localhost" (127.0.0.1), port 25432 failed: FATAL: no PostgreSQL user name specified in startup packet
To Reproduce I attached a minimal Program.cs connecting to a postgis database.
Expected behavior Based on my source code I would expect the Programm to open the database and print layer information.
Environment information:
Additional context
it is working, when I do
ogrinfo -ro "postgresql://docker:docker@localhost:25432/gis"
I actually suspect a libpq.so being packaged, that my OS doesn't use correctly.The postgis is running in a docker and is exposed to localhost via port: 25432.
Programm.cs