python connect to db2

Y

yuzx

hi,all

i am python newbie,i try to connect to db2 use python,i find it on
python-db2 doc:

$ python
>>> import DB2
>>> conn = DB2.connect(dsn='sample', uid='db2inst1', pwd='ibmdb2')
>>> curs = conn.cursor()

but i don't know about dsn,

i think a way like python connect to mysql :

db=_mysql.connect("localhost","joebob","moonpie","thangs")

anyone can help me ?

thank you
 
?

=?ISO-8859-1?Q?Michael_Str=F6der?=

yuzx said:
i try to connect to db2 use python,i find it on
python-db2 doc:

$ python
>>> import DB2
>>> conn = DB2.connect(dsn='sample', uid='db2inst1', pwd='ibmdb2')
>>> curs = conn.cursor()

but i don't know about dsn,

It's the host name. In a former project (using module DB2 together with
'IBM DB2 Connect' to access OS/390 database via TCP/IP) I had to invoke
a special catalog db2 script before being able to use the host name.

Ciao, Michael.
 
J

Jarek Zgoda

yuzx said:
>>> conn = DB2.connect(dsn='sample', uid='db2inst1', pwd='ibmdb2')

but i don't know about dsn,

If the database is DB2/400 and you try to connect from iSeries, dsn
would be '*local' for local database, or its name (not hostname or IP
address!) as returned by dsprdbdire command for remote databases.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top