[GRASS-dev] how to find out current working db driver and database?

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)?

Michael


C. Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

Phone: 480-965-6262
Fax: 480-965-7671
www: <www.public.asu.edu/~cmbarton>

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 <glynn@gclements.plus.com>