[gdal-dev] PostgreSQL driver for GDAL1.8.1

Dmitry Baryshnikov polimax at mail.ru
Sat May 12 04:17:28 EDT 2012


12.05.2012 12:00, Siju Wu ???????:
> Hi,
> I began using the GDAL for my master projet last month. Before I 
> used OGR to read directly the maps of shapefile. But now I need to 
> store the data first in the database of PostgreSQL and then make 
> access to the database by using the driver of OGR. However I found 
> that I can't connect the database by using the 
> function OGRSFDriverRegistrar::Open( source, FALSE ). My code is as below:
>
>
> OGRRegisterAll();
> OGRDataSource *poDS;
>
> poDS = OGRSFDriverRegistrar::Open( "PG:dbname='postgis' 
> host='localhost'        port='5432' user='postgres' 
> password='postgres'", FALSE );
> if( poDS == NULL )
> {
> printf( "Open failed.\n" );
> exit( 1 );
> }
>
>
> the value of poDS is null. Is that means in the version of GDAL there 
> is no driver for the postgreSQL and I need to write it myself? I work 
> with VS2010 c++ and GDAL 1.8.1. Dose anyone know if there is method to 
> connect the PostgreSQL by using OGR?
>
> Thanks,
> -Michel
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
Hi Siju,
You can check an error message like this:
     const char* pszErr = CPLGetLastErrorMsg();

Also you can log debug messages like this:
     CPLSetConfigOption("CPL_DEBUG", "ON");
     CPLSetConfigOption("CPL_TIMESTAMP", "ON");
     CPLSetConfigOption("CPL_LOG_ERRORS", "ON");
     CPLSetConfigOption("CPL_LOG", "/some_path/gdal_err.log" );

Best regards,
     Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120512/dab8c2fb/attachment-0001.html


More information about the gdal-dev mailing list