Michael Barton wrote:

> As a start to fixing the currently broken table and column select  
> combo boxes in the wxPython GUI, is there some way to find out what  
> the current working setting is for the database driver and database  
> (i.e., path)?

The defaults can be obtained with "db.connect -p", while the
parameters used by a specific vector map can be obtained with
"v.db.connect -g".

lib/python/grass.py has interfaces to both of these:

        def db_connection():
            """Return the current database connection parameters
            (interface to `db.connect -p').
            """

returns a dictionary:

    kv = grass.db_connection()
    database = kv['database']
    driver = kv['driver']

while:

        def vector_db(map, layer = None, **args):
            """Return the database connection details for a vector map
            (interface to `v.db.connect -g').
            """

returns either a list:

    f = grass.vector_db(map, layer)
    if not f:
        grass.fatal("An error occured while running v.db.connect")
    layr = f[0]
    table = f[1]
    keycol = f[2]
    database = f[3]
    driver = f[4]

or a list of such lists if the "layer" argument is omitted.

Note: if you intend to parse the output from "v.db.connect -g"
yourself, use the (recently-added) fs= option. The default field
separator is a space, but the database may be a pathname, which might
contain spaces, particularly on Windows.

-- 
Glynn Clements <[EMAIL PROTECTED]>
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to