python connect to db2

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yuzx

    #1

    python connect to db2

    hi,all

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

    $ python[color=blue][color=green][color=darkred]
    >>> import DB2
    >>> conn = DB2.connect(dsn ='sample', uid='db2inst1', pwd='ibmdb2')
    >>> curs = conn.cursor()[/color][/color][/color]

    but i don't know about dsn,

    i think a way like python connect to mysql :

    db=_mysql.conne ct("localhost", "joebob","moonp ie","thangs")

    anyone can help me ?

    thank you

  • Michael Ströder

    #2
    Re: python connect to db2

    yuzx wrote:[color=blue]
    >
    > 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,[/color]

    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.

    Comment

    • Jacek

      #3
      Re: python connect to db2

      yuzx wrote:
      [color=blue]
      > anyone can help me ?[/color]

      this might help:



      jacek

      Comment

      • Jarek Zgoda

        #4
        Re: python connect to db2

        yuzx wrote:
        [color=blue]
        > >>> conn = DB2.connect(dsn ='sample', uid='db2inst1', pwd='ibmdb2')
        >
        > but i don't know about dsn,[/color]

        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/

        Comment

        Working...