123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>GRASS GIS manual: GRASS-SQLite driver</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <link rel="stylesheet" href="grassdocs.css" type="text/css">
- </head>
- <body bgcolor="white">
- <img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
- <!-- meta page description: SQLite driver -->
- <h1>SQLite driver in GRASS</h1>
- <h2>KEYWORDS</h2>
- database, attribute table, driver
- <h2>DESCRIPTION</h2>
- The SQLite driver is the default DBMI backend.
- <h2>Creating a SQLite database</h2>
- GRASS is automatically creating the SQLite database if it is not yet
- existing when the first table is created in the SQLite database. It
- is sufficient to define the connection (see next step).
- <h2>Connecting GRASS to SQLite</h2>
- The database name 'sqlite.db' is at user's choice.
- Also the file storage location can be freely chosen. If the database
- does not exist, it will be automatically created when database content
- is created:
- <div class="code"><pre>
- # example for storing DB in mapset directory (keep single quotes):
- db.connect driver=sqlite database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
- db.connect -p
- </pre></div>
- <h2>Supported SQL commands</h2>
- All SQL commands supported by SQLite (for limitations, see
- SQLite help page:
- <a href="http://www.sqlite.org/lang.html">SQL As Understood By SQLite</a> and
- <a href="http://www.sqlite.org/omitted.html">Unsupported SQL</a>).
- <h2>Operators available in conditions</h2>
- All SQL operators supported by SQLite.
- <h2>Browsing table data in DB</h2>
- A convenient SQLite front-end is <a href="http://sqlitebrowser.sourceforge.net/">sqlitebrowser</a>.
- To open a DB file stored within the current mapset,
- the following way is suggested (corresponds to above database connection):
- <div class="code"><pre>
- # fetch GRASS variables as shell environment variables:
- eval `g.gisenv`
- # use double quotes:
- sqlitebrowser "$GISDBASE/$LOCATION_NAME/$MAPSET"/sqlite/sqlite.db
- </pre></div>
- <!-- doesnt work yet, why?:
- ah, pending patch: http://www.sqlite.org/cvstrac/tktview?tn=1476
- <h2>Adding an unique ID column</h2>
- Import vector module require an unique ID column which can
- be generated as follows for a SQLite table:
- <div class="code"><pre>
- echo "
- ALTER TABLE mytable ADD ID integer;
- CREATE SEQUENCE mytable_seq;
- UPDATE mytabe SET ID = nextval('mytable_seq');
- DROP SEQUENCE mytable_seq;
- " | db.execute
- </pre></div>
- -->
- <h2>SEE ALSO</h2>
- <em>
- <a href="db.connect.html">db.connect</a>,
- <a href="db.execute.html">db.execute</a>,
- <a href="db.select.html">db.select</a>
- <br><br>
- <a href="sql.html">SQL support in GRASS GIS</a>
- <br><br>
- <a href="http://www.sqlite.org">SQLite web site</a>,
- <a href="http://www.sqlite.org/quickstart.html">SQLite manual</a>,
- <a href="http://www.sqlite.org/cvstrac/wiki?p=ManagementTools">sqlite - Management Tools</a>
- </em>
- <p>
- <i>Last changed: $Date$</i>
- <hr>
- <p><a href="index.html">Main index</a> - <a href="database.html">Database index</a> - <a href="topics.html">Topics index</a> - <a href="keywords.html">Keywords Index</a> - <a href="full_index.html">Full index</a></p>
- <p>© 2003-2013 <a href="http://grass.osgeo.org">GRASS Development Team</a>, GRASS GIS 7.0.svn Reference Manual</p>
- </body>
- </html>
|