grass-sqlite.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>GRASS GIS manual: GRASS-SQLite driver</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <link rel="stylesheet" href="grassdocs.css" type="text/css">
  7. </head>
  8. <body bgcolor="white">
  9. <img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
  10. <!-- meta page description: SQLite driver -->
  11. <h1>SQLite driver in GRASS</h1>
  12. <h2>KEYWORDS</h2>
  13. database, attribute table, driver
  14. <h2>DESCRIPTION</h2>
  15. The SQLite driver is the default DBMI backend.
  16. <h2>Creating a SQLite database</h2>
  17. GRASS is automatically creating the SQLite database if it is not yet
  18. existing when the first table is created in the SQLite database. It
  19. is sufficient to define the connection (see next step).
  20. <h2>Connecting GRASS to SQLite</h2>
  21. The database name 'sqlite.db' is at user's choice.
  22. Also the file storage location can be freely chosen. If the database
  23. does not exist, it will be automatically created when database content
  24. is created:
  25. <div class="code"><pre>
  26. # example for storing DB in mapset directory (keep single quotes):
  27. db.connect driver=sqlite database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
  28. db.connect -p
  29. </pre></div>
  30. <h2>Supported SQL commands</h2>
  31. All SQL commands supported by SQLite (for limitations, see
  32. SQLite help page:
  33. <a href="http://www.sqlite.org/lang.html">SQL As Understood By SQLite</a> and
  34. <a href="http://www.sqlite.org/omitted.html">Unsupported SQL</a>).
  35. <h2>Operators available in conditions</h2>
  36. All SQL operators supported by SQLite.
  37. <h2>Browsing table data in DB</h2>
  38. A convenient SQLite front-end is <a href="http://sqlitebrowser.sourceforge.net/">sqlitebrowser</a>.
  39. To open a DB file stored within the current mapset,
  40. the following way is suggested (corresponds to above database connection):
  41. <div class="code"><pre>
  42. # fetch GRASS variables as shell environment variables:
  43. eval `g.gisenv`
  44. # use double quotes:
  45. sqlitebrowser "$GISDBASE/$LOCATION_NAME/$MAPSET"/sqlite/sqlite.db
  46. </pre></div>
  47. <!-- doesnt work yet, why?:
  48. ah, pending patch: http://www.sqlite.org/cvstrac/tktview?tn=1476
  49. <h2>Adding an unique ID column</h2>
  50. Import vector module require an unique ID column which can
  51. be generated as follows for a SQLite table:
  52. <div class="code"><pre>
  53. echo "
  54. ALTER TABLE mytable ADD ID integer;
  55. CREATE SEQUENCE mytable_seq;
  56. UPDATE mytabe SET ID = nextval('mytable_seq');
  57. DROP SEQUENCE mytable_seq;
  58. " | db.execute
  59. </pre></div>
  60. -->
  61. <h2>SEE ALSO</h2>
  62. <em>
  63. <a href="db.connect.html">db.connect</a>,
  64. <a href="db.execute.html">db.execute</a>,
  65. <a href="db.select.html">db.select</a>
  66. <br><br>
  67. <a href="sql.html">SQL support in GRASS GIS</a>
  68. <br><br>
  69. <a href="http://www.sqlite.org">SQLite web site</a>,
  70. <a href="http://www.sqlite.org/quickstart.html">SQLite manual</a>,
  71. <a href="http://www.sqlite.org/cvstrac/wiki?p=ManagementTools">sqlite - Management Tools</a>
  72. </em>
  73. <p>
  74. <i>Last changed: $Date$</i>
  75. <hr>
  76. <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>
  77. <p>&copy; 2003-2013 <a href="http://grass.osgeo.org">GRASS Development Team</a>, GRASS GIS 7.0.svn Reference Manual</p>
  78. </body>
  79. </html>