Download mxODBC Connect User Manual and Installation Guide
Transcript
4. Using mxODBC Connect
4.3
mxODBC Connect Client Example
First, you have to setup a working mxODBC Connect Server on the
machine that has the ODBC drivers installed (see above).
4.3.1
Client Configuration
After you have a working server, you'll have to create a client side
configuration file.
Contents of the example connect-config.ini:
[Logging]
log_file = client.log
[mxODBCServerConnection]
host = 192.168.1.100
port = 6632
using_ssl = 0
The client in the above example will connect to a Windows based mxODBC
Connect Server which listens on 192.168.1.100:6632 with a plain
(unencrypted) socket.
4.3.2
Connecting to the mxODBC Connect Server
Your stand-alone mxODBC based application usually connects to the
database like this:
import mx.ODBC.Windows as ODBC
and then uses the ODBC object to reference the mxODBC API.
In order to use the mxODBC Connect Client you have to successfully
connect to an mxODBC Connect Server first to get a reference to an object
implementing the mxODBC API:
from mx.ODBCConnect.Client import ServerSession
session = ServerSession('connect-config.ini')
ODBC = session.open()
Creating a ServerSession instance connects to the mxODBC Connect
Server. The ServerSession instance represents your connection to the
mxODBC Connect Server, so you have to keep a reference to the object or
your connection will be lost.
41