2017-04-24 1 views
1

Informix와의 다중 연결을 만들려고합니다. 여기에있는 문제는 모든 서버와 데이터베이스에 동일한 이름이 있으므로이 이름을 읽어야하기 때문에 동시에 연결할 수없는 경우 고유해야합니다! Informixdb multiple connections

는 지금은 명령을 사용하려고 해요 :
os.putenv('INFORMIXSQLHOSTS','/home/informix/etc/sqlhosts1') 

그래서 나는 여러 SQLHOSTS 파일을 사용할 수 있습니다,하지만이 작동하지 않습니다. 또한, 나는 나쁜 습관을 가지고 있으므로 올바른 방법을 찾고 있습니다.
cms_net 

는 또한 데이터베이스 이름은 다음과 같습니다 :

cms 

모두 다른 IP 서버에서

나는 이름으로 4 개 서버가.

누군가가 올바른 방법으로 이들에 연결할 수 있기를 바랍니다.

답변

1

연결 문자열에서 호스트를 덮어 쓸 수 있습니다. 나는라는 기계에 정의 된 "irk1210"가

(I는 서버 이름으로 그냥 "irk1210"를 사용하여 연결할 수 있습니다 파이썬 (I가 사용중인 무엇 추측)에서

[email protected]:/usr3/products/12.10$ grep irk1210 $INFORMIXSQLHOSTS 
irk1210shm onipcshm irk irk1210shm 
irk1210 onsoctcp 9.20.143.225 3046 
dr_irk1210 drsoctcp irk 3047 

"IRK" info)이있는 sqlhosts 파일에서

[email protected]:/usr3/products/12.10$ python 
Python 2.7.3 (default, Oct 26 2016, 21:04:23) 
[GCC 4.6.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import informixdb 
>>> conn = informixdb.connect('[email protected]',user='informix',password='ximrofni') 
>>> print conn 
<_informixdb.Connection object at 0x9d287a0> 
>>> 

을 집어 또는 (서버/프로토콜/호스트/서비스)

[email protected]:/usr3/products/12.10$ python 
Python 2.7.3 (default, Oct 26 2016, 21:04:23) 
[GCC 4.6.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import informixdb 
>>> conn = informixdb.connect('[email protected]|onsoctcp|9.20.143.225|3046',user='informix',password='ximrofni') 
>>> print conn 
<_informixdb.Connection object at 0x93c37a0> 
>>> 
01 서버에 대한 전체 정보를 지정한다 나중을하는 23,516,

당신에게 서버에 대한 다른 호스트 (IP)을 지정할 수있는 옵션을 제공합니다 : 나는 10.1.1.10에는 서버가 없지만 그것이 가지 것을 증명하기 때문에

[email protected]:/usr3/products/12.10$ python 
Python 2.7.3 (default, Oct 26 2016, 21:04:23) 
[GCC 4.6.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import informixdb 
>>> conn = informixdb.connect('[email protected]|onsoctcp|10.1.1.10|3046',user='informix',password='ximrofni') 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
_informixdb.OperationalError: SQLCODE -908 in CONNECT: 
08004: Client unable to establish connection 
IX000: ISAM error: record is locked. 

>>> 

나는 -908 오류가 발생했습니다를 드라이버가 irk1210 서버의 SQLHOSTS에 지정된 것과 다른 IP에 연결하려고 시도 중입니다

+0

작동합니다! 고마워!! 너는 내 목숨을 구해! – Urkidy

+0

나는 sqlhosts env hack보다 낫다고 생각한다. 8) –

+0

예! 하하 thx !! – Urkidy