GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
python.db Namespace Reference

Functions

def db_describe
 Return the list of columns for a database table (interface to `db.describe -c').
def db_connection
 Return the current database connection parameters (interface to `db.connect -p').
def db_select
 Perform SQL select statement.

Function Documentation

def python.db.db_connection ( )

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

Example:

>>> grass.db_connection()
{'group': 'x', 'schema': '', 'driver': 'dbf', 'database': '$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'}
Returns:
parsed output of db.connect

Definition at line 73 of file db.py.

References python.core.parse_key_val(), and python.core.read_command().

def python.db.db_describe (   table,
  args 
)

Return the list of columns for a database table (interface to `db.describe -c').

Example:

>>> grass.db_describe('lakes')
{'nrows': 15279, 'cols': [['cat', 'INTEGER', '11'], ['AREA', 'DOUBLE PRECISION', '20'],
['PERIMETER', 'DOUBLE PRECISION', '20'], ['FULL_HYDRO', 'DOUBLE PRECISION', '20'],
['FULL_HYDR2', 'DOUBLE PRECISION', '20'], ['FTYPE', 'CHARACTER', '24'],
['FCODE', 'INTEGER', '11'], ['NAME', 'CHARACTER', '99']], 'ncols': 8}
Parameters:
tabletable name
args
Returns:
parsed module output

Definition at line 33 of file db.py.

References python.core.fatal(), and python.core.read_command().

def python.db.db_select (   table,
  sql,
  file = False,
  args 
)

Perform SQL select statement.

Parameters:
tabletable name
sqlSQL select statement (string or file)
fileTrue if sql is filename
argssee db.select arguments

Definition at line 87 of file db.py.

References python.core.fatal(), gui_modules.render.map, python.core.run_command(), and python.core.try_remove().