[GRASS5] Re: [GRASSLIST:2865] php PostgreSQL frenzy - schema support in 5.7??

Radim Blazek blazek at itc.it
Thu Apr 15 09:26:23 EDT 2004


On Monday 08 March 2004 10:15, Radim Blazek wrote:
> On Monday 08 March 2004 21:21, francesco.pirotti wrote:
> > Hi,
> >
> > I am on this crazy train writing scripts to make GRASS call phpPgAdmin (a
> > PostgreSQL database manager based on PHP scripting)
> > and viceversa.
> >
> > 1 -There is a question.  If I use v.in.ogr to throw my attributes table
> > in a pg database which has several schemas, the SQL scripts gives me an
> > error because I do not specify the schema.  Usually the schema is
> > specified with its name before a dot before the table name.  For example:
> > CREATE TABLE myschema.mytable
> > The problem is that I do not know where to specify schema name in GRASS
> > 5.7.  Is there a way??
> >
> > Thank you
> > Francesco
>
> Currently schemas are not supported in 5.7.
> I think, that it should be without problems to add optional 'schema'
> to v.database (set GV_SCHEMA) and append schema name to the table name in
> Vect_default_field_info().
>
> Try to add in grass51/lib/vector/Vlib/field.c at row 276:
> if ( G__getenv2 ( "GV_SCHEMA", G_VAR_MAPSET ) )
>     sprintf ( buf, "%s.%s", G__getenv2 ( "GV_SCHEMA", G_VAR_MAPSET ),
> fi->table ); fi->table = G_store ( buf );
> }
> then add in text editor in $GISDBASE/$LOCATION_NAME/$MAPSET/VAR row:
> GV_SCHEMA: myschema
>
> let us know if it works, I don't have postgres with schemas.
>
> Radim

I have done that in CVS. Use v.database schema=myschema to set default
schema for new vector tables. The schema is stored with table name
in dbln (qualified name). 
In db.* modules the schema name must be always specified if used.

Example:
v.database driver=pg database=test schema=user1
v.in.ogr dsn=./ layer=river output=river # -> table user1.river
db.select table=user1.river

You can ignore schemas, if you want:
v.database driver=pg database=test
v.in.ogr dsn=./ layer=river output=river # -> table public.river
db.select table=river

Radim




More information about the grass-dev mailing list