#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    36
    Rep Power
    10

    mysql affected rows


    how can I learn affected rows after a query with python ?

    I am using MySQLdb for included. does it support the function which like mysql_affected_rows like php ?

    best regards
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Yes, there's a method called affectedrows() which should do what you want. You can see an example/semi-explanation of this here.

    Hope this helps,

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    36
    Rep Power
    10

    it doesn't work


    thank you mark,

    but the sample for python 1.5.1 and I am using 2.3.4
    and MySQLdb

    accessing mysql in the sample is very well for me .
    because it like php

    importing mysql begin of the code, not mysqldb.

    this mysql module is different from mysqldb or it is old version of mysqldb.


    regards
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Sorry, i hadnt expected them to change the interface . Silly me. Anyway, this page: http://phplens.com/lens/adodb/adodb-py-docs.htm seems to think that you can use th Affected_Rows() method. Wether or not this is true i dont know.

    Ill install MySQLdb and let you know. I really need to learn how to build MySQL on Unix anyway .

    Mark.
    programming language development: www.netytan.com Hula

  8. #5
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Ok, scratch that. After installing MySQL 4.0.20 and MySQLdb 1.0.0 on my IBook you can clearly see that the method is called affected_rows()... Which prompts me to say, STOP changing the name guys .

    >>> dir(connection)
    ['DataError', 'DatabaseError', 'Error', 'IntegrityError', 'InterfaceError', 'InternalError', 'NotSupportedError', 'OperationalError', 'ProgrammingError', 'Warning', '__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_make_connection', '_transactional', 'affected_rows', 'begin', 'change_user', 'character_set_name', 'client_flag', 'close', 'commit', 'converter', 'cursor', 'cursorclass', 'default_cursor', 'dump_debug_info', 'errno', 'error', 'errorhandler', 'escape', 'escape_string', 'field_count', 'get_host_info', 'get_proto_info', 'get_server_info', 'info', 'insert_id', 'kill', 'literal', 'messages', 'open', 'ping', 'port', 'query', 'rollback', 'select_db', 'server_capabilities', 'shutdown', 'stat', 'store_result', 'string_literal', 'thread_id', 'unicode_literal', 'use_result']
    >>>
    So in theory that should do it .

    Take care,

    Mark.
    programming language development: www.netytan.com Hula

  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    36
    Rep Power
    10

    it works


    thanks mark,

    it works.
    I tried it yesterday but I couldn't find affected_rows function
    because I guess I should be try to dir(result)
    but I have to check dir(connection)

    whatever, I write script to help me.
    it works like that,

    it take functions about a value and docs and write to screen with for ,

    aa = dir(value)
    for a in aa:
    print a, "\n help : \n", a.__doc__ , "\n\n"


    something like that.
    I can see which functions I can use with my variables.
    but I dont know yet how can I add this script to under site-packages

    if I can add a python module, I can call it everytime when I need it like a function.


    thanks again, mohikan
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Im a little comfused, nothing new there . It is working though right?

    If you want to add a script to site-packages just save the file and move it into the site-packages directory. You should then be able to import it without any problems.

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo