File: unixodbc.HOWTO

package info (click to toggle)
postgresql 7.2.1-2woody8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 42,424 kB
  • ctags: 30,027
  • sloc: ansic: 290,568; java: 18,529; sh: 12,197; sql: 11,401; yacc: 11,189; tcl: 8,063; perl: 4,067; makefile: 3,332; xml: 2,874; lex: 2,799; python: 1,237; cpp: 845; pascal: 81; asm: 70; awk: 20; sed: 8
file content (48 lines) | stat: -rw-r--r-- 1,918 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
HOW TO set up odbc-postgresql with unixodbc to allow access to other
Unix programs
====================================================================

1. Install packages unixodbc and odbcinst1

2. Add a PostgreSQL driver to /etc/odbcinst.ini:

   # odbcinst -i -d -f /usr/lib/postgreql/share/odbcinst.ini.template

3. Add the template1 database (with read only access) to the default odbc.ini

   # cat /usr/lib/postgreql/share/odbc.ini.template >>/etc/odbc.ini

   Edit /etc/odbc.ini as required, to add extra databases, change the read only
   status and so on.

4. Add ODBC required functions to the databases that you wish to access
   from ODBC:

   # su - postgres
   $ for dbname in database1 database2 ...
     do
        psql -d  $dbname < /usr/lib/postgresql/sahre/odbc.sql
     done

   If you include template1 in the list, any database created in future will
   automatically have these functions included when it is created.


At this point, you should be able to use the ODBC access features of anyr
application to connect to any of the listed databases.   For example, in
StarOffice, you can click New->Database, select the ODBC database type
and browse the list of databases from /etc/odbc.ini and ~/.odbc.ini.


Each user has or can have a file ~/.odbc.ini, whose structure is the same
as /etc/odbc.ini.  This file is read together with the /etc/odbc.ini to give
a complete list of databases accessible to the user.  (Of course, any
access restrictions imposed by pg_hba.conf are still applicable.)

You can create templates for different databases and allow users to add
them to their own ~/.odbc.ini.  Use the odbc.ini template file provided in
/usr/lib/postgreql/lib/odbcinst.ini.template as a model.  A good and
reliable way for a user to add this template to his ~/.odbc.ini without
risk of damaging his file is for him to use this command:

  $ odbcinst -i -s -f /path/to/your/template/file