db.connect.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <h2>DESCRIPTION</h2>
  2. <em>db.connect</em> allows the user to set database connection parameters.
  3. These parameters are then taken as default values by modules so that the
  4. user does not need to enter the parameters each time.
  5. <p>
  6. The default database backend in GRASS GIS 7
  7. is <a href="grass-sqlite.html">SQLite</a>.
  8. <h2>NOTES</h2>
  9. Values are stored in the mapset's <tt>VAR</tt> file;
  10. the connection is not tested for validity.
  11. <p>The <b>-p</b> flag will display the current connection parameters.
  12. <p>The <b>-c</b> flag will silently check if the connection parameters have
  13. been set, and if not will set them to use GRASS's default values.
  14. (useful in scripts before you attempt to create a new database table)
  15. <p>To connect a vector map to a database table,
  16. use <em><a href="v.db.connect.html">v.db.connect</a></em> or
  17. <em><a href="v.db.addtable.html">v.db.addtable</a></em>.
  18. <h2>EXAMPLES</h2>
  19. <h3>SQLite (default backend)</h3>
  20. Local storage:
  21. <br>
  22. <div class="code"><pre>
  23. db.connect -d
  24. db.connect -p
  25. db.tables -p
  26. </pre></div>
  27. <p>The SQLite database file is created automatically when used the first time.
  28. <p>See <a href="grass-sqlite.html">SQLite</a> database driver for details.
  29. <h3>PostgreSQL (local connection)</h3>
  30. Local storage, database tables stored in database "mydb"
  31. (may require the use of <em><a href=db.login.html>db.login</a></em>):
  32. <br>
  33. <div class="code"><pre>
  34. db.connect driver=pg database=mydb
  35. db.login user=myname pass=secret
  36. db.connect -p
  37. db.tables -p
  38. </pre></div>
  39. <p>See <a href="grass-pg.html">PostgreSQL</a> database driver for details.
  40. <h3>PostgreSQL (network connection)</h3>
  41. Network storage, database tables stored in database "mydb"
  42. (may require the use of <em><a href=db.login.html>db.login</a></em>):
  43. <br>
  44. <div class="code"><pre>
  45. db.connect driver=pg database=mydb
  46. db.login user=myname pass=secret host=myserver.com port=6666
  47. db.connect -p
  48. db.tables -p
  49. </pre></div>
  50. <p>See <a href="grass-pg.html">PostgreSQL</a> database driver for details.
  51. <h3>MySQL (local connection)</h3>
  52. Local storage, database tables stored in database "mydb" (may require
  53. the use of <em><a href=db.login.html>db.login</a></em>):
  54. <br>
  55. <div class="code"><pre>
  56. db.connect driver=mysql database=mydb
  57. db.login user=myname pass=secret
  58. db.connect -p
  59. db.tables -p
  60. </pre></div>
  61. <p>See <a href="grass-mysql.html">MySQL</a> database driver for details.
  62. <h3>MySQL (network connection)</h3>
  63. Network storage, database tables stored in database "mydb"
  64. (may require the use of <em><a href=db.login.html>db.login</a></em>):
  65. <br>
  66. <div class="code"><pre>
  67. db.connect driver=mysql database=mydb
  68. db.login user=myname pass=secret host=myserver.com
  69. db.connect -p
  70. db.tables -p
  71. </pre></div>
  72. <p>See <a href="grass-mysql.html">MySQL</a> database driver for details.
  73. <h3>ODBC</h3>
  74. Network storage, database tables stored in database "mydb"
  75. (may require the use of <em><a href=db.login.html>db.login</a></em>):
  76. <br>
  77. <div class="code"><pre>
  78. db.connect driver=odbc database=mydb
  79. db.login user=myname pass=secret
  80. db.connect -p
  81. db.tables -p
  82. </pre></div>
  83. <p>See <a href="grass-odbc.html">ODBC</a> database driver for details.
  84. <h3>DBF (local, not recommended)</h3>
  85. Local storage (the dbf/ subdirectory in the mapset must exist or must be
  86. created by the user):
  87. <br>
  88. <div class="code"><pre>
  89. db.connect driver=dbf database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'
  90. db.tables -p
  91. </pre></div>
  92. <p>See <a href="grass-dbf.html">DBF</a> database driver for details.
  93. <h2>SEE ALSO</h2>
  94. <em>
  95. <a href="db.columns.html">db.columns</a>,
  96. <a href="db.copy.html">db.copy</a>,
  97. <a href="db.drivers.html">db.drivers</a>,
  98. <a href="db.login.html">db.login</a>,
  99. <a href="db.tables.html">db.tables</a>,
  100. <a href="v.db.addtable.html">v.db.addtable</a>,
  101. <a href="v.db.connect.html">v.db.connect</a>
  102. </em>
  103. <p>
  104. <a href="sql.html">GRASS SQL interface</a>
  105. <h2>AUTHORS</h2>
  106. Main author: Radim Blazek, ITC-Irst, Trento, Italy<br>
  107. GRASS 7 improvements: Martin Landa, Markus Metz
  108. <p>
  109. <i>Last changed: $Date$</i>