python connect to db2

Discussion in 'Python' started by yuzx, Jan 14, 2005.

  1. yuzx

    yuzx Guest

    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
     
    yuzx, Jan 14, 2005
    #1
    1. Advertising

  2. yuzx wrote:
    >
    > 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.
     
    =?ISO-8859-1?Q?Michael_Str=F6der?=, Jan 14, 2005
    #2
    1. Advertising

  3. yuzx

    Jacek Guest

    Jacek, Jan 14, 2005
    #3
  4. yuzx

    Jarek Zgoda Guest

    yuzx wrote:

    > >>> 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.

    --
    Jarek Zgoda
    http://jpa.berlios.de/ | http://www.zgodowie.org/
     
    Jarek Zgoda, Jan 14, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kate Perry

    connect to db2 database using dbi?

    Kate Perry, Jul 10, 2003, in forum: Perl
    Replies:
    0
    Views:
    3,259
    Kate Perry
    Jul 10, 2003
  2. Replies:
    1
    Views:
    10,939
    jeak110
    Jul 27, 2005
  3. Replies:
    0
    Views:
    7,640
  4. Dinesh
    Replies:
    0
    Views:
    172
    Dinesh
    Apr 3, 2006
  5. Replies:
    0
    Views:
    190
Loading...

Share This Page