Which Python module for PostgreSQL?

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

    Which Python module for PostgreSQL?

    Hi,

    I'm not new to Python, but new to databases and PostgreSQL.
    I like to write a PostgreSQL client application (not code
    running inside of the RDBMS), and Debian has four modules:

    python2.3-pgsql - A Python DB-API 2.0 interface to PostgreSQL v7.x
    python2.3-popy - module providing access to PostgreSQL from Python2.3
    python2.3-psycopg - Python 2.3 module for PostgreSQL
    python2.3-pygresql - PostgreSQL module for Python

    Now I'm confused: Which one should I use? I'm going to try
    python2.3-psycopg, but maybe the other variants are "easier
    to use"? Or faster? Or more complete? Thread-safe?

    Thanks in advance for your hints!

    Cheers,
    --
    W. Borgert <debacle@debian .org>

  • Ganesan R

    #2
    Re: Which Python module for PostgreSQL?

    >>>>> "W" == W Borgert <debacle@debian .org> writes:
    [color=blue]
    > Hi,
    > I'm not new to Python, but new to databases and PostgreSQL.
    > I like to write a PostgreSQL client application (not code
    > running inside of the RDBMS), and Debian has four modules:[/color]
    [color=blue]
    > python2.3-pgsql - A Python DB-API 2.0 interface to PostgreSQL v7.x
    > python2.3-popy - module providing access to PostgreSQL from Python2.3
    > python2.3-psycopg - Python 2.3 module for PostgreSQL
    > python2.3-pygresql - PostgreSQL module for Python[/color]

    I prefer the first one - it's BSD licensed, actively maintained and
    supported. It's also very compatible with the python SQLite binding which I
    use regularly.

    Ganesan

    --
    Ganesan R

    Comment

    • simo

      #3
      Re: Which Python module for PostgreSQL?

      I'd like to know too - I had a play with psychog but couldn't get it
      to connect, and couldn't find any documentation for it.

      I don't have a huge amount of PostgreSQL knowledge (more of a MySQL
      person myself) so I could have it setup wrong, but I couldn't figure
      anything out as the error message was useless (something about IDENT
      user).

      Comment

      • Rene Pijlman

        #4
        Re: Which Python module for PostgreSQL?

        W. Borgert:[color=blue]
        >python2.3-pgsql - A Python DB-API 2.0 interface to PostgreSQL v7.x
        >python2.3-popy - module providing access to PostgreSQL from Python2.3
        >python2.3-psycopg - Python 2.3 module for PostgreSQL
        >python2.3-pygresql - PostgreSQL module for Python
        >
        >Now I'm confused: Which one should I use?[/color]

        I scanned the newsgroups and documentation with the same question some
        time ago. I can't remember all the reasons, but I chose pgsql. No regrets.

        --
        René Pijlman

        Comment

        • Gerhard Häring

          #5
          Re: Which Python module for PostgreSQL?

          simo wrote:[color=blue]
          > I'd like to know too - I had a play with psychog but couldn't get it
          > to connect, and couldn't find any documentation for it.
          >
          > I don't have a huge amount of PostgreSQL knowledge (more of a MySQL
          > person myself) so I could have it setup wrong, but I couldn't figure
          > anything out as the error message was useless (something about IDENT
          > user).[/color]

          It's a PostgreSQL question, really. It sounds like the user account you're trying
          to connect to the database from doesn't have the necessary permissions. I can
          hardly imagine that a copy-and-paste strategy of the exact error message into
          Google wouldn't have led you further ;-)

          -- Gerhard

          Comment

          • Skip Montanaro

            #6
            Re: Which Python module for PostgreSQL?


            simo> I'd like to know too - I had a play with psychog but couldn't get
            simo> it to connect, and couldn't find any documentation for it.

            If you're familiar with SQL programming in Python in general, it's pretty
            straightforward . It does adhere to v2 of the DB API, so PEP-249 is useful
            reading. Also, see the doc/examples directory. Here's a psycopg "hello
            world" (change the connect arg to suit your server):

            import psycopg
            conn = psycopg.connect ('dbname=test user=test')
            curs = conn.cursor()
            curs.execute("" "select 'hello world'""")
            print curs.fetchall()

            Skip

            Comment

            • David M. Cook

              #7
              Re: Which Python module for PostgreSQL?

              In article <oueksar0tu.fsf @andlx-anamika.cisco.c om>, Ganesan R wrote:
              [color=blue][color=green]
              >> python2.3-pgsql - A Python DB-API 2.0 interface to PostgreSQL v7.x
              >> python2.3-popy - module providing access to PostgreSQL from Python2.3
              >> python2.3-psycopg - Python 2.3 module for PostgreSQL
              >> python2.3-pygresql - PostgreSQL module for Python[/color]
              >
              > I prefer the first one - it's BSD licensed, actively maintained and
              > supported. It's also very compatible with the python SQLite binding which I
              > use regularly.[/color]

              PyGreSQL (the first one), doesn't seem to handle boolean's correctly in
              Python 2.3. Is there a workaround (aside from translating back and forth
              before saving)? This is the version that ships with Red Hat 9.

              I use psycopg usually, though I try to test my progs with all of them
              (except popy). It's not too hard to accomadate all of them with just a few
              tweaks (usually in the way they handle booleans), since they all use
              pyformat.

              pyPgSQL does seem to have the best win32 support.

              Dave Cook

              Comment

              • Ganesan R

                #8
                Re: Which Python module for PostgreSQL?

                >>>>> "David" == David M Cook <davecook@nowhe re.net> writes:
                [color=blue]
                > In article <oueksar0tu.fsf @andlx-anamika.cisco.c om>, Ganesan R wrote:[color=green][color=darkred]
                >>> python2.3-pgsql - A Python DB-API 2.0 interface to PostgreSQL v7.x
                >>> python2.3-popy - module providing access to PostgreSQL from Python2.3
                >>> python2.3-psycopg - Python 2.3 module for PostgreSQL
                >>> python2.3-pygresql - PostgreSQL module for Python[/color]
                >>
                >> I prefer the first one - it's BSD licensed, actively maintained and
                >> supported. It's also very compatible with the python SQLite binding which I
                >> use regularly.[/color][/color]

                I was referring to python2.3-pgsql which is the same as pyPgSQL.
                [color=blue]
                > PyGreSQL (the first one), doesn't seem to handle boolean's correctly in
                > Python 2.3. Is there a workaround (aside from translating back and forth
                > before saving)? This is the version that ships with Red Hat 9.[/color]

                I presume you meant to say "the last one" :-).

                Ganesan

                --
                Ganesan R

                Comment

                • David M. Cook

                  #9
                  Re: Which Python module for PostgreSQL?

                  In article <ou7jy2qghn.fsf @andlx-anamika.cisco.c om>, Ganesan R wrote:
                  [color=blue]
                  > I was referring to python2.3-pgsql which is the same as pyPgSQL.[/color]

                  Oh, those wacky Debian kids and their renamings. I assumed pgsql was the
                  "standard" module that ships with postgres.

                  pyPgSQL seems to handle booleans quite transparently.

                  Dave Cook

                  Comment

                  • Gandalf

                    #10
                    Re: Which Python module for PostgreSQL?

                    >[color=blue]
                    >
                    >I use psycopg usually, though I try to test my progs with all of them
                    >(except popy). It's not too hard to accomadate all of them with just a few
                    >tweaks (usually in the way they handle booleans), since they all use
                    >pyformat.
                    >
                    >[/color]
                    Hmm, this is why I use C-style booleans (e.g. an integer where 0 means
                    false and not 0 means true).
                    It is totally portable (can be used with any DBMS and with any DB-API
                    module). I can be wrong doing
                    this but it works fine for me.

                    G



                    Comment

                    Working...