title: calling QgsDataSourceUri with QGIS for python plugin
body: <p>TLDR : using QGIS, I'm trying to develop a python plugin to update a database. Unfortunately I get immediatly an error : Traceback (most recent call last):
    File "", line 1, in 
  NameError: name 'QgsDataSourceUri' is not defined</p>
  
  <p>More detailed:</p>
  
  <p>I work on QGIS2.18 to develop a plugin to update some data located on a postgres database.
  for this, I want to use this kind of code:</p>
  
  <pre><code>from qgis.core import *
  from PyQt4.QtCore import *
  from PyQt4.QtCore import QSettings
  from PyQt4.QtCore import QSettings
  from qgis.core import QgsVectorLayer, QgsDataSourceURI
  
  uri = QgsDataSourceUri()
  
  # set host name, port, database name, username and password
  uri.setConnection(hote_IP, "5432", base_de_donnee, utilisateur,     mot_de_passe)
  # set database schema, table name, geometry column and optionally
  # subset (WHERE clause)
  #uri.setDataSource("public", "roads", "the_geom", "cityid = 2643")
  
  uri.setDataSource("", sql, "geom", "", "gid")
  vlayer = QgsVectorLayer(uri.uri(), zapm, "postgres")
  QgsMapLayerRegistry.instance().addMapLayer(vlayer)
  </code></pre>
  
  <p>(I got the code from the net, I'll adapt it later on)</p>
  
  <p>My problem : when I try to run this code on the Python console of QGIS, I immediatly get the error</p>
  
  <p><em>Traceback (most recent call last):
    File "", line 1, in 
  NameError: name 'QgsDataSourceUri' is not defined</em></p>
  
  <p>even when I only run the import and the line <em>uri = QgsDataSourceUri()</em>, I get the same error message.</p>
  
  <p>I have not been able to find out how to correct this issue.</p>
  
  <p>problem of installation of QGIS? of python? bad imports?</p>
  
  <p>Config:
  qgis 2.18.20
  python 3.6.5</p>
  
  <p>If anyone has an idea on how to solve this, I would be really glad.</p>
  
  <p>Thanks,
  Erwann</p>