MySQLdb "begin()" -

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shearichard@gmail.com

    #1

    MySQLdb "begin()" -

    Hi - Feeling a bit weird about this but I cannot find the 'begin'
    method on a connection object of MySQLdb. Can anyone explain why ?

    I'm using version 1.2.0 which is pretty recent and I've read that
    'begin' should be a method of connection but it's not there ! Feeling
    pretty puzzled !

    Below are the details of what I see ...

    [color=blue][color=green][color=darkred]
    >>> import MySQLdb
    >>> c= MySQLdb.Connect (host='localhos t', user='a',passwd ='b', db='c',compress =1)
    >>> c.begin()[/color][/color][/color]
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    AttributeError: 'Connection' object has no attribute 'begin'[color=blue][color=green][color=darkred]
    >>> o=MySQLdb
    >>> o.__version__[/color][/color][/color]
    '1.2.0'[color=blue][color=green][color=darkred]
    >>> o.__revision__[/color][/color][/color]
    '1.37'[color=blue][color=green][color=darkred]
    >>> o.apilevel[/color][/color][/color]
    '2.0'


    Be interested in any comments.

    regards

    Richard.

  • Geoffrey Clements

    #2
    Re: MySQLdb &quot;begin()&q uot; -

    <shearichard@gm ail.com> wrote in message
    news:1145973021 .073264.262180@ i39g2000cwa.goo glegroups.com.. .[color=blue]
    > Hi - Feeling a bit weird about this but I cannot find the 'begin'
    > method on a connection object of MySQLdb. Can anyone explain why ?
    >
    > I'm using version 1.2.0 which is pretty recent and I've read that
    > 'begin' should be a method of connection but it's not there ! Feeling
    > pretty puzzled !
    >[/color]

    What exactly do you expect a begin method to do? Have you read this:
    This API has been defined to encourage similarity between the Python modules that are used to access databases. By doing this, we hope to achieve a consistency leading to more easily understood modules, code that is generally more portable across datab...


    --
    Geoff


    Comment

    • shearichard@gmail.com

      #3
      Re: MySQLdb &quot;begin()&q uot; -

      "What do i expect the begin method to do" ?

      Explicitly start a transaction (and therefore suppress autocommits) in
      an environment where autocommit is on.

      No i haven't read the pep, thanks for that.

      Comment

      • shearichard@gmail.com

        #4
        Re: MySQLdb &quot;begin()&q uot; -

        Thanks for your advice. In fact subsquent to posting I started using
        ....

        conn.autocommit = False

        .... as a synonm for ...

        conn.begin()

        .... and as you say that does the job. (Sorry i should have said it's
        not practicable to turn off autocommit always [or rather it may be but
        I'm not about to shake the boat to that extent just now ;-]

        As to what I was reading yes it's here ...

        http://www.devshed.com/index2.php?op...ge=0&hide_js=1

        .... or more succinctly ...

        http://tinyurl.com/s6yd2

        .... page down to ...

        "connection.beg in() - start a transaction"

        .... that article refers to version 0.92 of MySQLdb so clearly it was
        either wrong then or for some weird reason the method has been dropped.

        thanks again.

        richard.

        Comment

        Working...