通过ODBC连接Postgresql
http://tech.ddvip.com 2007年10月26日 社区交流
本文详细介绍通过ODBC连接Postgresql
D. 创建一个库
$ createdb
E. 连接新的数据库
$ psql
F. 运行简单的请求
postgres SELECT datetime 'now';
G. 退出psql
postgres=> q
H. 增加postgres用户
$ su - postgres
$ createuser michele
Enter user's postgres ID or RETURN to use unix user ID: 500 ->
Is user "tester" allowed to create databases (y/n) y
Is user "tester" a superuser? (y/n) y
createuser: tester was successfully added
I. 给用户增加一个数据库
$ su -
$ createdb
4. 配置Applixware
A. 编辑 /opt/applix/axdata/axnet.cnf 文件,增加下几行 :
libFor gsqlodbc /opt/applix/axdata/axshlib/
注意: 在applixware 5.0或更高的版本中这个步骤取消
B. 增加"axnet" 到 /etc/services
axnet 5492/tcp # Applix comms process
C. 在后台启动Applix axnet程序:
$ /opt/applix/axdata/axnet &
D. 接着创建".odbc.ini"文件,在用户home目录下:
[ODBC Data Sources]
Postgresql=Postgresql database
[Postgresql]
Driver=/usr/local/pgsql/lib/libpsqlodbc.so
Database=michele
Server=localhost
Port=5432
ReadOnly=0
[ODBC]
Trace=1
TraceFile=/tmp/odbctrace.out
InstallDir=/opt/applix/axdata/axshlib
注意: 在Applixware 5.0 包含一个 postgresql 驱动程序叫做 libodbcpsql.so 在/axdata/axshlib. 如果你想用在axnet.cnf中的ODBCINI变量你就必须要用这个驱动。
E. 启动 Applix Data 连接Postgresql
1. Start Applix Data
2. Select Query->Choose Server
3. Select the ShelfSQL tab
4. Choose the gateway "Shelf ODBC"
5. Click on "Specify Connection Info..."
6. In the ODBC Connection dialog click on Browse and choose the "Postgresql" selection and click OK; this sets the "Datasource" field
7. Click OK in "Choose Server" dbox
8. Enter your username for the login and type the password to the database that you created earlier. You should see it successfully connect (It will show a status of "Ready" in the lower left-hand corner of the Data window)
责编:豆豆技术应用