Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 29 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,32 @@ default: true
fix: true

MD041: false # first-line-h1

# Errors from .html to .md rename (first step in HTML to Markdown conversion)
MD001: false # heading-increment
MD003: false # heading-style
MD004: false # ul-style
MD007: false # ul-indent
MD009: false # no-trailing-spaces
MD010: false # no-hard-tabs
MD011: false # no-reversed-links
MD012: false # no-multiple-blanks
MD013: false # line-length
MD018: false # no-missing-space-atx
MD019: false # no-multiple-space-atx
MD020: false # no-missing-space-closed-atx
MD022: false # blanks-around-headings
MD023: false # heading-start-left
MD024: false # no-duplicate-heading
MD026: false # no-trailing-punctuation
MD029: false # ol-prefix
MD032: false # blanks-around-lists
MD033: false # no-inline-html
MD034: false # no-bare-urls
MD037: false # no-space-in-emphasis
MD045: false # no-alt-text
MD049: false # emphasis-style
MD052: false # reference-links-images
MD055: false # table-pipe-style
MD058: false # blanks-around-tables
# The block above this is to be eventually removed.
105 changes: 105 additions & 0 deletions db/databaseintro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!-- meta page description: Database management in GRASS GIS -->
<!-- meta page index: database -->
<h3>Attribute management in general</h3>

GRASS can be linked to one or many database management systems (DBMS).
The <em>db.*</em> set of commands provides basic SQL support for
attribute management, while the <em>v.db.*</em> set of commands operates
on the vector map (see <a href="vectorintro.html">Vector introduction</a>).

<h3>Available drivers</h3>

Available drivers are listed in <a href="sql.html">SQL support in GRASS GIS</a>.
<p>
<b>Notes</b>:<br>
The DBF driver provides only very limited SQL
support (as DBF is not an SQL DB) while the other DBMS backends (such
as SQLite, PostgreSQL, MySQL etc) provide full SQL support since the SQL
commands are sent directly to the DBMS. For this reason, the SQLite driver
is the default DBMI backend.

<h3>DB connection management</h3>

The current database management settings are shown or modified with
<a href="db.connect.html">db.connect</a> for current mapset. Available DBMI drivers
are listed with <a href="db.drivers.html">db.drivers</a>. Some DBMI backends
require a user/password for driver/database to be set with <a href="db.login.html">db.login</a>.
In order to test a driver, run <a href="db.test.html">db.test</a>.

<h3>Attribute data import and export</h3>

Attribute data can be imported with <a href="db.in.ogr.html">db.in.ogr</a> from
various formats and exported with <a href="db.out.ogr.html">db.out.ogr</a>. To internally
copy a a full table or selectively parts of it, use <a href="db.copy.html">db.copy</a>.
<p>

Further conversion tools:
<ul>
<li><a href="https://github.com/mdbtools/mdbtools">MDB Tools</a>: Convert MS-Access data to SQL, DBF, etc.</li>
<li><a href="https://grasswiki.osgeo.org/wiki/Openoffice.org_with_SQL_Databases">Using OpenOffice.org with SQL Databases</a></li>
</ul>


<h3>SQL commands</h3>

GRASS supports two main SQL operations, execution of an SQL statement
(<a href="db.execute.html">db.execute</a>) and selection
of data from a table (<a href="db.select.html">db.select</a>).
See the <a href="sql.html">SQL help page</a> for examples.

<h3>Managing the default DBMI settings</h3>

Per default vector map attributes are stored in SQLite tables. This default
definition can be modified with <a href="db.connect.html">db.connect</a>. If an
external DBMS is used, <a href="db.login.html">db.login</a> may be required.

<h3>Creating a database</h3>

Specific commands are explained on the individual driver pages (these
pages are only available if driver was compiled in this installation):

<ul>
<li>DBF: see <a href="grass-dbf.html">DBF</a> page</li>
<li>SQLite: <a href="grass-sqlite.html">SQLite</a> page</li>
<li>mySQL: <a href="grass-mysql.html">mySQL</a> and <a href="grass-mesql.html">meSQL</a> pages</li>
<li>ODBC: <a href="grass-odbc.html">ODBC</a> page (connect to Oracle, etc.)</li>
<li>PostgreSQL: <a href="grass-pg.html">PostgreSQL</a> and PostGIS page</li>
</ul>

<h3>Metadata</h3>
All columns for a given table are listed with <a href="db.columns.html">db.columns</a>.
The command <a href="db.describe.html">db.describe</a> describes a table in detail. To
list all available tables for a given database, run <a href="db.tables.html">db.tables</a>.

<h3>Table maintenance</h3>
To drop a column from a selected attribute table, use <a href="db.dropcolumn.html">db.dropcolumn</a>.
With <a href="db.droptable.html">db.droptable</a> an attribute table can be deleted.

<h3>Database Schema</h3>
Currently schema support only works for PostgreSQL connections. Default schema
can be set with <a href="db.connect.html">db.connect</a>. Note that the default
schema will be used by all db.* modules.
<p>
<a href="db.tables.html">db.tables</a> returns 'schema.table' if schemas are
available in the database.

<h3>Migrating to a different database engine</h3>

To migrate a GRASS database table (or a GRASS vector map) to a different DBMI engine,
the best solution is to create a new MAPSET, define the DBMI settings accordingly
with <a href="db.connect.html">db.connect</a> and if needed, <a href="db.login.html">db.login</a>.
Then the table of interest can be copied over with <a href="db.copy.html">db.copy</a> from
the original MAPSET. Likewise, a vector map including its table(s) are copied from
the original MAPSET to the current MAPSET with <a href="g.copy.html">g.copy</a>.

<h3>See also</h3>

<ul>
<li><a href="rasterintro.html">Introduction into raster data processing</a></li>
<li><a href="raster3dintro.html">Introduction into 3D raster data (voxel) processing</a></li>
<li><a href="vectorintro.html">Introduction into vector data processing</a></li>
<li><a href="imageryintro.html">Introduction into image processing</a></li>
<li><a href="temporalintro.html">Introduction into temporal data processing</a></li>
<li><a href="projectionintro.html">Projections and spatial transformations</a></li>
<li><a href="wxguiintro.html">Graphical User Interface</a></li>
</ul>
59 changes: 59 additions & 0 deletions db/db.columns/db.columns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<h2>DESCRIPTION</h2>

<em>db.columns</em> lists all columns for a give table. Connection to
databases are supported through dbf, shp, odbc and pg drivers.

<h2>NOTE</h2>

If parameters for database connection are already set with
<a href="db.connect.html">db.connect</a>, they are taken as default values
and do not need to be spcified each time.

<h2>EXAMPLES</h2>

<h3>List columns of a PostgreSQL attribute table</h3>

<div class="code"><pre>
db.columns table=zipcodes_wake driver=pg database=grassdb
</pre></div>

<p>
<em>If the database parameters are already set, the columns can be listed
directly</em><br>

<div class="code"><pre>
db.columns table=zipcodes_wake
</pre></div>

<h3>List columns from Shape file with DBF attribute table</h3>

<div class="code"><pre>
db.columns table=zipcodes_wake driver=dbf database=/grassdata/nc_spm_08/PERMANENT/dbf/
</pre></div>

<h3>List columns of table in SQLite database</h3>

Note that the SQLite backend is the default setting.

<div class="code"><pre>
db.columns driver=sqlite table=archsites database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
</pre></div>

<h2>SEE ALSO</h2>

<em>
<a href="db.connect.html">db.connect</a>,
<a href="db.describe.html">db.describe</a>,
<a href="db.drivers.html">db.drivers</a>,
<a href="db.droptable.html">db.droptable</a>,
<a href="db.execute.html">db.execute</a>,
<a href="db.login.html">db.login</a>,
<a href="db.tables.html">db.tables</a>,
<a href="sql.html">GRASS SQL interface</a>
</em>
<p>
<a href="sql.html">GRASS SQL interface</a>

<h2>AUTHOR</h2>

Radim Blazek, ITC-Irst, Trento, Italy
130 changes: 130 additions & 0 deletions db/db.connect/db.connect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<h2>DESCRIPTION</h2>

<em>db.connect</em> allows the user to set database connection parameters.
These parameters are then taken as default values by modules so that the
user does not need to enter the parameters each time.
<p>
The default database backend in GRASS GIS
is <a href="grass-sqlite.html">SQLite</a> (since version 7).

<h2>NOTES</h2>

Values are stored in the mapset's <code>VAR</code> file;
the connection is not tested for validity.
<p>The <b>-p</b> flag will display the current connection parameters.
<p>The <b>-c</b> flag will silently check if the connection parameters have
been set, and if not will set them to use GRASS's default values.
(useful in scripts before you attempt to create a new database table)
<p>To connect a vector map to a database table,
use <em><a href="v.db.connect.html">v.db.connect</a></em> or
<em><a href="v.db.addtable.html">v.db.addtable</a></em>.

<h2>EXAMPLES</h2>

<h3>SQLite (default backend)</h3>

Local storage:
<br>
<div class="code"><pre>
db.connect -d
db.connect -p
db.tables -p
</pre></div>
<p>The SQLite database file is created automatically when used the first time.
<p>See <a href="grass-sqlite.html">SQLite</a> database driver for details.

<h3>PostgreSQL (local connection)</h3>

Local storage, database tables stored in database "mydb"
(may require the use of <em><a href="db.login.html">db.login</a></em>):
<br>
<div class="code"><pre>
db.connect driver=pg database=mydb
db.login user=myname pass=secret
db.connect -p
db.tables -p
</pre></div>
<p>See <a href="grass-pg.html">PostgreSQL</a> database driver for details.

<h3>PostgreSQL (network connection)</h3>

Network storage, database tables stored in database "mydb"
(may require the use of <em><a href="db.login.html">db.login</a></em>):
<br>
<div class="code"><pre>
db.connect driver=pg database=mydb
db.login user=myname pass=secret host=myserver.com port=6666
db.connect -p
db.tables -p
</pre></div>
<p>See <a href="grass-pg.html">PostgreSQL</a> database driver for details.

<h3>MySQL (local connection)</h3>

Local storage, database tables stored in database "mydb" (may require
the use of <em><a href="db.login.html">db.login</a></em>):
<br>
<div class="code"><pre>
db.connect driver=mysql database=mydb
db.login user=myname pass=secret
db.connect -p
db.tables -p
</pre></div>
<p>See <a href="grass-mysql.html">MySQL</a> database driver for details.

<h3>MySQL (network connection)</h3>

Network storage, database tables stored in database "mydb"
(may require the use of <em><a href="db.login.html">db.login</a></em>):
<br>
<div class="code"><pre>
db.connect driver=mysql database=mydb
db.login user=myname pass=secret host=myserver.com
db.connect -p
db.tables -p
</pre></div>
<p>See <a href="grass-mysql.html">MySQL</a> database driver for details.

<h3>ODBC</h3>

Network storage, database tables stored in database "mydb"
(may require the use of <em><a href="db.login.html">db.login</a></em>):
<br>
<div class="code"><pre>
db.connect driver=odbc database=mydb
db.login user=myname pass=secret
db.connect -p
db.tables -p
</pre></div>
<p>See <a href="grass-odbc.html">ODBC</a> database driver for details.

<h3>DBF (local, not recommended)</h3>

Local storage (the dbf/ subdirectory in the mapset must exist or must be
created by the user):
<br>
<div class="code"><pre>
db.connect driver=dbf database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'
db.tables -p
</pre></div>
<p>See <a href="grass-dbf.html">DBF</a> database driver for details.

<h2>SEE ALSO</h2>

<em>
<a href="db.columns.html">db.columns</a>,
<a href="db.copy.html">db.copy</a>,
<a href="db.drivers.html">db.drivers</a>,
<a href="db.login.html">db.login</a>,
<a href="db.tables.html">db.tables</a>,
<a href="v.db.addtable.html">v.db.addtable</a>,
<a href="v.db.connect.html">v.db.connect</a>
</em>

<p>
<a href="sql.html">GRASS SQL interface</a>

<h2>AUTHORS</h2>

Main author: Radim Blazek, ITC-Irst, Trento, Italy<br>
GRASS 7 improvements: Martin Landa, Markus Metz
Loading
Loading