UnixODBC
view release on metacpan or search on metacpan
UnixODBC.pm is known to work with MySQL and PostgreSQL on Linux
and Solaris systems.
Running, "make test," makes sure that the library modules load
correctly.
The dbms/test.pl script excercises the unixODBC API more
thoroughly. For the script to complete, the DBMS must have
installed the test data in the dbms/ subdirectory, and you must
have configured a DSN for the test data. Refer to the file
dbms/README for notes about MySQL and PostgreSQL DBMS's.
Running test.pl is likely to result in at least a few errors.
The script is designed to test the subset of ODBC API functions
that UnixODBC.pm implements as exhaustively as possible, and as
many different ODBC DBMS drivers as possible (currently
Connector/ODBC for MySQL, and libodbcpsql and psqlODBC for
PostgreSQL).
- Installing and Configuring the Bridge Server
IMPORTANT (Again) - The versions of Perl, Net::Daemon, Storable,
and PlRPC on each host MUST be the identical. Net::Daemon,
in particular, checks for version information when authenticating,
and PlRPC generates protocol errors when communicating with different
versions. Storable also relies having the same version of itself and
Perl on local and remote systems.
Net::Daemon errors are commonly recorded in the syslog.
Although you can configure the log messages, check the syslog
first. Refer to, "Troubleshooting," below.
The bridge server runs as user nobody and uses port 9999. To
change the configuration, edit /usr/local/etc/odbcbridge.conf
after installation. The RPC::PlServer(3) man page describes the
settings Example server and client scripts are in the bridge/
subdirectory. For further examples of writing Perl RPC clients
and servers, refer to the man pages for RPC::PlServer and
RPC::PlClient, and the ProxyServer.pm module in the Perl DBI
bundle.
Install UnixODBC.pm as describe above. This step also installs
/usr/local/etc/odbclogins which is necessary for the Web data
manager. You can add host and login information as described below.
If the installation proceeded correctly, the core libraries and
bridge server daemon should be installed in the proper directories,
and you should be able to start and stop the daemon by typing:
# /usr/local/etc/init.d/unixodbc start
# /usr/local/etc/init.d/unixodbc stop
- Manual Installation
Install the bridge server manually with the following shell
commands.
$ su
# mkdir /usr/local/var/odbcbridge
# chown nobody /usr/local/var/odbcbridge
# cp bridge/odbcbridge.conf /usr/local/etc
# cp bridge/odbclogins /usr/local/etc
# chmod 0600 /usr/local/etc/odbclogins
# chown nobody /usr/local/etc/odbclogins
# mkdir /usr/local/etc/init.d
# cp bridge/unixodbc /usr/local/etc/init.d
# cp bridge/odbcbridge /usr/local/sbin
# chmod +x /usr/local/sbin/odbcbridge
If everything is installed correctly, you should be able
to start and stop the server by typing:
# /usr/local/etc/init.d/unixodbc start
# /usr/local/etc/init.d/unixodbc stop
To start the server when the system starts, install the unixodbc
script in the same directory as the other local startup scripts.
Refer to the system administration documents for information
about how to start daemons during system initialization.
- Installing the GUI Data Manager, Tkdm
The GUI data manager tkdm is installed when UnixODBC.pm is
installed. Refer to the man page ("man tkdm") and the
tkdm/README file for configuration instructions.
- Installing the Web data manager
The Web data manager works with the Web servers: Apache 1.3 and
2.0, and the Web browsers: Mozilla 1.0, Netscape 4.75, and Internet
Explorer 3.03.
The document describes a configuration that uses
/usr/local/apache/htdocs as the Apache DocumentRoot directory and
/usr/local/apache/cgi-bin as the CGI script directory. Make the
necessary adjustments for the system's Apache configuration.
APACHE CONFIGURATION - Httpd.conf must be configured to load mod_perl,
mod_env, and mod_ssi, and use server-side includes. On some systems,
LD_LIBRARY_PATH in the server's environment must be able to locate all
of the libraries that the DBMS server, ODBC, and Perl require.
The data manager is configured to be installed in the, "datamanager,"
subdirectory of, "htdocs," or the directory named in the httpd.conf
DocumentRoot directive. If installing in a different subdirectory,
modify the directives shown below for httpd.conf accordingly, and
change the value of $folder in the CGI script, datamanager.cgi.
If the Apache server does not have server-side includes enabled,
add the following lines to httpd.conf:
<Directory "/usr/local/apache/htdocs/datamanager">
Options FollowSymLinks Includes
</Directory>
For Apache 1.3.x, uncomment the following lines in httpd.conf.
AddType text/html .shtml
AddHandler server-parsed .shtml
For Apache 2.0.x, uncomment these lines in httpd.conf.
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
To add the path for all of the libraries to the server's
environment, add a line like this to httpd.conf:
SetEnv LD_LIBRARY_PATH /usr/lib:/usr/local/lib:/usr/local/mysql/lib/mysql
The specific names of the directories depend on the system's
Apache and DBMS server configuration.
Then restart the Apache:
# /usr/local/apache/bin/apachectl restart
Then install the files.
$ su
# mkdir /usr/local/apache/htdocs/datamanager
# cp datamanager/*.html /usr/local/apache/htdocs/datamanager
# cp datamanager/*.shtml /usr/local/apache/htdocs/datamanager
# cp datamanager/*.gif /usr/local/apache/icons
# cp datamanger/odbclogins /usr/local/etc
# cp datamanager/*.cgi /usr/local/apache/cgi-bin
# cd /usr/local/apache/cgi-bin
# chmod +x tables.cgi datamanager.cgi odbclogin.cgi
Edit the path to the perl interpreter on the
first line of tables,cgi, datamanager.cgi,
odbclogin.cgi to the path of the actual perl
interpreter. The path should be either
/usr/local/bin/perl, /usr/bin/perl, or the output
of the shell command, "which perl."
# cd /usr/local/etc
# chmod 0600 odbclogins
# chown nobody odbclogins # Use the UID/GID of httpd.conf's,
# chgrp nobody odbclogins # "User," and, "Group," directives.
Edit each line of the file /usr/local/etc/odbclogins for
the login of each system that has a bridge server installed.
The format of each line is:
host::user::password
The user names and passwords need not be the same as those
used to log in to the DSN's. They simply need to allow the
clients (either the CGI scripts or the command-line scripts)
to log in to the bridge server on the remote system. They
need to be actual users with passwords, with their own
entries in /etc/passwd.
IMPORTANT - /usr/local/etc/odbclogins contains login data
for remote systems. It is important to change the permissions
and ownership so that it can be read by the httpd server
processes ONLY (i.e., the CGI scripts). Apache servers often run
as user nobody, group nobody. The ownership of
/usr/local/etc/odbclogins should be the values of the User and
Group http.conf directives.
Also, do a, "chmod 0600 /usr/local/etc/odbclogins," to remove,
"group," and, "other," permissions from the file. If this isn't
secure enough, you can also create a separate UID (www, for
example) and make sure to change the User directive value in
httpd.conf.
Standard Disclaimer (Again) - The CGI scripts are written to
find Perl as /usr/bin/perl. If that isn't the location of the
Perl interpreter, then either edit the first line of the scripts
to reflect the actual location of the perl binary (the output of,
"which perl") or make /usr/bin/perl symlink to the interpreter.
The ODBC logo is modified from the XPM in the unixODBC-2.2.2
Data Manager source tree.
CGI script errors are recorded in the Apache error_log, even if
they don't appear in the browser window. If the scripts seem
to work right, but the data manager can't connect to data sources,
look for the bridge error messages in the syslog, and consult the
section, "Troubleshooting," below.
- Text-mode Programs
The eg/ subdirectory contains example ODBC clients for
locally hosted ODBC servers. The scripts that log into a
data source require the DSN, DBMS login name and DBMS
password as command line arguments. The client scripts in
the bridge/ subdirectory, for networked ODBC servers,
additionally require the name or IP address of the host
system.
Documentation for the client scripts are in the man pages.
The command line option, "--help," prints a brief help
message.
# alltypes --help
( run in 0.573 second using v1.01-cache-2.11-cpan-5511b514fd6 )