OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.66k stars 2.46k forks source link

"MSSQLSpatial" not available (GDAL 3.6.2, released 2023/01/02) #7347

Closed NMItools closed 1 year ago

NMItools commented 1 year ago

I was trying to import some data into MS SQL Server with ogr2ogr as before

I am using

gdalinfo --version
GDAL 3.6.2, released 2023/01/02

ogr2ogr -f MSSQLSpatial "MSSQL:server=verdi;database=GIS;UID=*****;PWD=*****" "Warsaw_district.gpkg" -a_srs "EPSG:3857"

but I got this message:

ERROR 1: Unable to find driver 'MSSQLSpatial'.

Also, ogrinfo does not show "MSSQLSpatial" as a supported format like before?

ogrinfo --formats

Supported Formats:
  AmigoCloud -vector- (rw+): AmigoCloud
  Arrow -vector- (rw+v): (Geo)Arrow IPC File Format / Stream
  AVCBin -vector- (rov): Arc/Info Binary Coverage
  AVCE00 -vector- (rov): Arc/Info E00 (ASCII) Coverage
  CAD -raster,vector- (rovs): AutoCAD Driver
  Carto -vector- (rw+): Carto
  CSV -vector- (rw+v): Comma Separated Value (.csv)
  CSW -vector- (ro): OGC CSW (Catalog  Service for the Web)
  DGN -vector- (rw+v): Microstation DGN
  DXF -vector- (rw+v): AutoCAD DXF
  EDIGEO -vector- (rov): French EDIGEO exchange format
  EEDA -vector- (ro): Earth Engine Data API
  Elasticsearch -vector- (rw+): Elastic Search
  ESRI Shapefile -vector- (rw+v): ESRI Shapefile
  ESRIJSON -vector- (rov): ESRIJSON
  FlatGeobuf -vector- (rw+v): FlatGeobuf
  Geoconcept -vector- (rw+v): Geoconcept
  GeoJSON -vector- (rw+v): GeoJSON
  GeoJSONSeq -vector- (rw+v): GeoJSON Sequence
  GeoRSS -vector- (rw+v): GeoRSS
  GML -vector- (rw+v): Geography Markup Language (GML)
  GMLAS -vector- (rwv): Geography Markup Language (GML) driven by application schemas
  GPKG -raster,vector- (rw+vs): GeoPackage
  GPSBabel -vector- (rw+): GPSBabel
  GPX -vector- (rw+v): GPX
  HTTP -raster,vector- (ro): HTTP Fetching Wrapper
  Idrisi -vector- (rov): Idrisi Vector (.vct)
  Interlis 1 -vector- (rw+v): Interlis 1
  Interlis 2 -vector- (rw+v): Interlis 2
  JML -vector- (rw+v): OpenJUMP JML
  JP2ECW -raster,vector- (rw+v): ERDAS JPEG2000 (SDK 5.5)
  JP2OpenJPEG -raster,vector- (rwv): JPEG-2000 driver based on OpenJPEG library
  KML -vector- (rw+v): Keyhole Markup Language (KML)
  LIBKML -vector- (rw+v): Keyhole Markup Language (LIBKML)
  LVBAG -vector- (rov): Kadaster LV BAG Extract 2.0
  MapInfo File -vector- (rw+v): MapInfo File
  MapML -vector- (rw+v): MapML
  MBTiles -raster,vector- (rw+v): MBTiles
  Memory -vector- (rw+): Memory
  MVT -vector- (rw+v): Mapbox Vector Tiles
  MySQL -vector- (rw+): MySQL
  NAS -vector- (rov): NAS - ALKIS
  netCDF -raster,multidimensional raster,vector- (rw+s): Network Common Data Format
  NGW -raster,vector- (rw+s): NextGIS Web
  OAPIF -vector- (ro): OGC API - Features
  ODBC -vector- (ro):
  ODS -vector- (rw+v): Open Document/ LibreOffice / OpenOffice Spreadsheet
  OGCAPI -raster,vector- (rov): OGCAPI
  OGR_GMT -vector- (rw+v): GMT ASCII Vectors (.gmt)
  OGR_OGDI -vector- (ro): OGDI Vectors (VPF, VMAP, DCW)
  OGR_PDS -vector- (rov): Planetary Data Systems TABLE
  OGR_SDTS -vector- (rov): SDTS
  OGR_VRT -vector- (rov): VRT - Virtual Datasource
  OpenFileGDB -vector- (rw+v): ESRI FileGDB
  OSM -vector- (rov): OpenStreetMap XML and PBF
  Parquet -vector- (rw+v): (Geo)Parquet
  PCIDSK -raster,vector- (rw+v): PCIDSK Database File
  PDF -raster,vector- (rw+vs): Geospatial PDF
  PDS4 -raster,vector- (rw+vs): NASA Planetary Data System 4
  PGDUMP -vector- (w+v): PostgreSQL SQL dump
  PGeo -vector- (ro): ESRI Personal GeoDatabase
  PLSCENES -raster,vector- (ro): Planet Labs Scenes API
  PostgreSQL -vector- (rw+): PostgreSQL/PostGIS
  S57 -vector- (rw+v): IHO S-57 (ENC)
  Selafin -vector- (rw+v): Selafin
  SQLite -vector- (rw+v): SQLite / Spatialite
  SVG -vector- (rov): Scalable Vector Graphics
  SXF -vector- (rov): Storage and eXchange Format
  TIGER -vector- (rov): U.S. Census TIGER/Line
  TopoJSON -vector- (rov): TopoJSON
  UK .NTF -vector- (rov): UK .NTF
  VDV -vector- (rw+v): VDV-451/VDV-452/INTREST Data Format
  VFK -vector- (ro): Czech Cadastral Exchange Data Format
  VICAR -raster,vector- (rw+v): MIPL VICAR file
  WAsP -vector- (rw+v): WAsP .map format
  WFS -vector- (rov): OGC WFS (Web Feature Service)
  XLS -vector- (ro): MS Excel format
  XLSX -vector- (rw+v): MS Office Open XML spreadsheet

Any explanation?

szekerest commented 1 year ago

@NMItools If you use the GISInternals builds, this issue due to that the MSSQLSpatial driver with the legacy ODBC driver hasn't been compiled in by default. You should either install the MSSQL plugin with that build, use the stable branch (daily) build or wait for the 3.6.3 release where it will be fixed.

NMItools commented 1 year ago

Thank you for the fast answer! In the meanwhile I have found that from the newer QGIS network installer version, there is

gdalmss: OGR plugin with SQL Native Client support for MSSQL Bulk Copy

as an option, so I have install it and now MSSQLSpatial appeared as an MSSQLSpatial -vector- (rw+): Microsoft SQL Server Spatial Database (BCP)

Now it is working but I have to specify the driver in the connection string and a config parameter --config MSSQLSPATIAL_USE_BCP to NO since my driver does not support BCP (from message)

ERROR 1: SQL Error SQLState=HY000, NativeError=0, Msg=[Microsoft][SQL Server Native Client 11.0]Connection is not enabled for BCP

So the working version (without BCP) is:

ogr2ogr -f "MSSQLSpatial" "MSSQL:server=verdi;database=GIS;driver=SQL Server Native Client 11.0;UID=***;PWD=***" "Warsaw_district.shp" -a_srs "EPSG:3857" --config MSSQLSPATIAL_USE_BCP NO

szekerest commented 1 year ago

In the meantime recompiled the stable releases with the MSSQL driver compiled in by default. Closing this issue.