Skip to content
Permalink
Browse files

fix #2009

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12922 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Feb 10, 2010
1 parent 363ba98 commit b402d2912b32f6751eada6b9166d4d2c54c358b3
Showing with 58 additions and 11 deletions.
  1. +58 −11 src/app/ogr/qgsogrhelperfunctions.cpp
@@ -24,35 +24,66 @@
QString createDatabaseURI( QString connectionType, QString host, QString database, QString port, QString user, QString password )
{
QString uri = "";

//todo:add default ports for all kind of databases
if ( connectionType == "ESRI Personal GeoDatabase" )
{
uri = "PGeo:" + database;
}
else if ( connectionType == "ESRI ArcSDE" )
{
if ( port.isNull() || port.isEmpty() )
if ( port.isEmpty() )
port = "5151";

uri = "SDE:" + host + ",PORT:" + port + "," + database + "," + user + "," + password;
}
else if ( connectionType == "Informix DataBlade" )
{
//not tested
uri = "IDB:dbname=" + database + " server=" + host
+ " user=" + user
+ " pass=" + password + " ";
uri = "IDB:dbname=" + database;

if ( !host.isEmpty() )
uri += QString( " server=%1" ).arg( host );

if ( !user.isEmpty() )
{
uri += QString( " user=%1" ).arg( user );

if ( !password.isEmpty() )
uri += QString( " pass=%1" ).arg( password );
}
}
else if ( connectionType == "INGRES" )
{
//not tested
uri = "@driver=ingres,dbname=" + database + ",userid=" + user + ", password=" + password + " ";
uri = "@driver=ingres,dbname=" + database;
if ( !user.isEmpty() )
{
uri += QString( ",userid=%1" ).arg( user );

if ( !password.isEmpty() )
uri += QString( ",password=%1" ).arg( password );
}
}
else if ( connectionType == "MySQL" )
{
uri = "MySQL:" + database + ",host=" + host
+ ",port=" + port + ",user=" + user
+ ", password=" + password + " ";
uri = "MySQL:" + database;

if ( !host.isEmpty() )
{
uri += QString( ",host=%1" ).arg( host );

if ( !port.isEmpty() )
uri += QString( ",port=%1" ).arg( port );
}

if ( !user.isEmpty() )
{
uri += QString( ",user=%1" ).arg( user );

if ( !password.isEmpty() )
uri += QString( ",password=%1" ).arg( password );
}
}
else if ( connectionType == "Oracle Spatial" )
{
@@ -97,11 +128,27 @@ QString createDatabaseURI( QString connectionType, QString host, QString databas
}
else if ( connectionType == "PostgreSQL" )
{
uri = "PG:dbname='" + database + "' host='" + host
+ "' port='" + port + "' user='" + user
+ "' password='" + password + "' ";
uri = "PG:dbname='" + database + "'";

if ( !host.isEmpty() )
{
uri += QString( " host='%1'" ).arg( host );

if ( !port.isEmpty() )
uri += QString( " port='%1'" ).arg( port );
}

if ( !user.isEmpty() )
{
uri += QString( " user='%1'" ).arg( user );

if ( !password.isEmpty() )
uri += QString( " password='%1'" ).arg( password );
}

uri += " ";
}

QgsDebugMsg( "Connection type is=" + connectionType + " and uri=" + uri );
return uri;
}

0 comments on commit b402d29

Please sign in to comment.
You can’t perform that action at this time.