Skip to content

Commit

Permalink
Converted with with c745b4c from cwhite911:docs-html-to-markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzeslaus committed Feb 7, 2025
1 parent f9fe03d commit b14f3c6
Show file tree
Hide file tree
Showing 495 changed files with 2,225 additions and 2,594 deletions.
8 changes: 4 additions & 4 deletions db/db.columns/db.columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ need to be spcified each time.

### List columns of a PostgreSQL attribute table

```shell
```sh
db.columns table=zipcodes_wake driver=pg database=grassdb
```

*If the database parameters are already set, the columns can be listed
directly*

```shell
```sh
db.columns table=zipcodes_wake
```

### List columns from Shape file with DBF attribute table

```shell
```sh
db.columns table=zipcodes_wake driver=dbf database=/grassdata/nc_spm_08/PERMANENT/dbf/
```

### List columns of table in SQLite database

Note that the SQLite backend is the default setting.

```shell
```sh
db.columns driver=sqlite table=archsites database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
```

Expand Down
14 changes: 7 additions & 7 deletions db/db.connect/db.connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To connect a vector map to a database table, use

Local storage:

```shell
```sh
db.connect -d
db.connect -p
db.tables -p
Expand All @@ -44,7 +44,7 @@ See [SQLite](grass-sqlite.md) database driver for details.
Local storage, database tables stored in database "mydb" (may require
the use of *[db.login](db.login.md)*):

```shell
```sh
db.connect driver=pg database=mydb
db.login user=myname pass=secret
db.connect -p
Expand All @@ -58,7 +58,7 @@ See [PostgreSQL](grass-pg.md) database driver for details.
Network storage, database tables stored in database "mydb" (may require
the use of *[db.login](db.login.md)*):

```shell
```sh
db.connect driver=pg database=mydb
db.login user=myname pass=secret host=myserver.com port=6666
db.connect -p
Expand All @@ -72,7 +72,7 @@ See [PostgreSQL](grass-pg.md) database driver for details.
Local storage, database tables stored in database "mydb" (may require
the use of *[db.login](db.login.md)*):

```shell
```sh
db.connect driver=mysql database=mydb
db.login user=myname pass=secret
db.connect -p
Expand All @@ -86,7 +86,7 @@ See [MySQL](grass-mysql.md) database driver for details.
Network storage, database tables stored in database "mydb" (may require
the use of *[db.login](db.login.md)*):

```shell
```sh
db.connect driver=mysql database=mydb
db.login user=myname pass=secret host=myserver.com
db.connect -p
Expand All @@ -100,7 +100,7 @@ See [MySQL](grass-mysql.md) database driver for details.
Network storage, database tables stored in database "mydb" (may require
the use of *[db.login](db.login.md)*):

```shell
```sh
db.connect driver=odbc database=mydb
db.login user=myname pass=secret
db.connect -p
Expand All @@ -114,7 +114,7 @@ See [ODBC](grass-odbc.md) database driver for details.
Local storage (the dbf/ subdirectory in the mapset must exist or must be
created by the user):

```shell
```sh
db.connect driver=dbf database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'
db.tables -p
```
Expand Down
10 changes: 5 additions & 5 deletions db/db.copy/db.copy.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ in the file *\$LOCATION/vector_map/dbln*.
*Storing table 'geonames.dbf' (in current directory) into PostgreSQL
through ODBC:*

```shell
```sh
db.copy from_driver=dbf from_database='$GISDBASE/$LOCATION_NAME/PERMANENT/dbf' \
from_table=geonames to_driver=pg to_database="host=pgserver,dbname=testdb" \
to_table=geonames
```

### From PostgreSQL to DBF

```shell
```sh
db.copy from_driver=pg from_database="host=pgserver.example.org,dbname=testdb" \
from_table=origtable to_driver=dbf \
to_database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf' to_table=origtable
```

### From PostgreSQL to PostgreSQL with condition

```shell
```sh
db.copy from_driver=pg from_database="host=localhost,dbname=testdb" \
from_table=geonames to_driver=pg to_database="host=localhost,dbname=testdb" \
to_table=selection where="cat < 500"
```

### From DBF to SQLite

```shell
```sh
db.copy from_driver=dbf from_database='$GISDBASE/$LOCATION_NAME/PERMANENT/dbf' \
from_table=geonames_features to_driver=sqlite \
to_database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db' to_table=geonames_features
Expand All @@ -53,7 +53,7 @@ sqlitebrowser $HOME/grassdata/nc_spm_08/user1/sqlite/sqlite.db

### From SQLite to DBF

```shell
```sh
db.copy from_driver=sqlite from_database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db' \
from_table=ammprv to_driver=dbf to_database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/' \
to_table=ammprv
Expand Down
6 changes: 3 additions & 3 deletions db/db.createdb/db.createdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Note that the standard GRASS GIS SQLite database is by default generated
in the user's current mapset. This example shows an out-of-mapset
database file creation:

```shell
```sh
db.createdb driver=sqlite database=/opt/sqlite.db
```

Expand All @@ -24,14 +24,14 @@ db.createdb driver=sqlite database=/opt/sqlite.db
Create a new PostgreSQL database (after the PostgreSQL connection got
established through the *pg* driver):

```shell
```sh
db.createdb driver=pg database=grassdb
```

Create a new PostgreSQL database (after the PostgreSQL connection got
established through the *odbc* driver):

```shell
```sh
db.createdb driver=odbc database=grassdb
```

Expand Down
6 changes: 3 additions & 3 deletions db/db.databases/db.databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ mapset. For PostgreSQL driver it's empty connection string.

List SQLite databases in the current mapset:

```shell
```sh
db.databases driver=sqlite
```

List SQLite databases in a given directory:

```shell
```sh
db.databases driver=sqlite location=/opt/sqlite
```

List PostgreSQL databases from database server running on given port:

```shell
```sh
db.databases driver=pg location="host=server_name port=5333"
```

Expand Down
12 changes: 5 additions & 7 deletions db/db.describe/db.describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ need to be spcified each time.
*List column descriptions of table in SQLite database (note that this is
the default setting)*

```shell
```sh
db.describe driver=sqlite table=hospitals \
database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'

Expand All @@ -24,7 +24,7 @@ db.describe myarchsites

### DBF example

```shell
```sh
db.describe -c table=hospitals database='$GISDBASE/$LOCATION_NAME/PERMANENT/dbf/' \
driver=dbf
ncols: 16
Expand All @@ -34,8 +34,7 @@ Column 2: OBJECTID:INTEGER:11
Column 3: AREA:DOUBLE PRECISION:20
[...]
```

```shell
```sh
db.describe table=hospitals database='$GISDBASE/$LOCATION_NAME/PERMANENT/dbf/' \
driver=dbf
table:hospitals
Expand Down Expand Up @@ -64,11 +63,10 @@ type:INTEGER

### JSON Output

```shell
```sh
db.describe table=hospitals format=json
```

```shell
```sh
{
"table": "hospitals",
"description": "",
Expand Down
2 changes: 1 addition & 1 deletion db/db.drivers/db.drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Show all installed GRASS database drivers:

```shell
```sh
db.drivers -p
pg
ogr
Expand Down
4 changes: 2 additions & 2 deletions db/db.dropdb/db.dropdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Note that the standard GRASS GIS SQLite database is by default found in
the user's current mapset. This example shows an out-of-mapset database
removal:

```shell
```sh
db.dropdb driver=sqlite database=/opt/sqlite.db
```

### Drop an existing database connected through PostgreSQL driver

```shell
```sh
db.dropdb driver=pg database=grassdb
```

Expand Down
24 changes: 12 additions & 12 deletions db/db.execute/db.execute.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,70 +25,70 @@ create a new database.

Create a new table with columns 'cat' and 'soiltype':

```shell
```sh
db.execute sql="CREATE TABLE soils (cat integer, soiltype varchar(10))"
```

Create a new table using a file with SQL statements

```shell
```sh
db.execute driver=odbc database=grassdb input=file.sql
```

Insert new row into attribute table:

```shell
```sh
db.execute sql="INSERT INTO mysites (id,name,east,north) values (30,'Ala',1657340,5072301)"
```

Update attribute entries to new value based on SQL rule:

```shell
```sh
db.execute sql="UPDATE roads SET travelcost=5 WHERE cat=1"
```

Update attribute entries to new value based on SQL rule:

```shell
```sh
db.execute sql="UPDATE dourokukan SET testc=50 WHERE testc is NULL"
```

Delete selected rows from attribute table:

```shell
```sh
db.execute sql="DELETE FROM gsod_stationlist WHERE latitude < -91"
```

Add new column to attribute table:

```shell
```sh
db.execute sql="ALTER TABLE roads ADD COLUMN length double"
```

Column type conversion - update new column from existing column (all
drivers except for DBF):

```shell
```sh
# 'z_value' is varchar and 'z' is double precision:
echo "UPDATE geodetic_pts SET z = CAST(z_value AS numeric)" | db.execute input=-
```

Drop column from attribute table:

```shell
```sh
db.execute sql="ALTER TABLE roads DROP COLUMN length"
```

Drop table (not supported by all drivers):

```shell
```sh
db.execute sql="DROP TABLE fmacopy"
```

Update attribute with multiple SQL instructions in file (e.g.,
`file.sql`, instruction line must end with a semicolon):

```shell
```sh
UPDATE roads SET travelcost=5 WHERE cat=1;
UPDATE roads SET travelcost=2 WHERE cat=2;

Expand All @@ -98,7 +98,7 @@ db.execute input=file.sql
Join table 'myroads' to table 'extratab' based on common 'cat' column
values (not supported by DBF driver):

```shell
```sh
db.execute sql="UPDATE extratab SET names=(SELECT label FROM myroads WHERE extratab.cat=myroads.cat)"
```

Expand Down
6 changes: 3 additions & 3 deletions db/db.login/db.login.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ Only the file owner can access this file.
Only username specified (assuming locally accessible PostgreSQL DB
without password):

```shell
```sh
db.login driver=pg database=mydb
```

Username, password and hostname specified (note that the command lines
history will store the password in this way):

```shell
```sh
db.login driver=pg database=mydb user=bacava password=secret host=db.example.com
```

Username and empty password specified:

```shell
```sh
db.login driver=pg database=mydb user=bacava password=""
```

Expand Down
Loading

0 comments on commit b14f3c6

Please sign in to comment.