Menu

Do I need to connect/disconnect every trans?

Help
2010-02-16
2012-09-19
  • Hirohito Kinjyo

    Hirohito Kinjyo - 2010-02-16

    I would like to make daily movement report which has over 1500 items

    First I refer to which date have Incoming and Outgoing transaction

    Second I refer which parts and qty I have transaction

    I have made 2 programs, one for day by day I inquire do I have Incoming
    transaction today, do I have Outgoing transaction today, which Items are
    involved and how many qty

    The other one is in one shot all daily transaction for incoming,outgoing, Item
    and qty generated by one Stored procedure.

    First one, say storing days into days variable to loop, each day I inquire
    Incoming Item and Qty, Outgoing Item and Qty

    If I do that, say 20 days/month, 100 incoming, 1200 outgoing, require many
    inquiry to DB

    it show very unstable "(item, qty)" supposed to be returned but sometimes

    (None,qty)=(there is qty say 8 but no Item) only return without errors, not
    always same place(incoming,outgoing)

    Second one, number of return records are a lot so that not able to execute.

    Before I inquire to DB, I must connect, after inquire do I need to disconnect
    ?

     
  • Andy Dustman

    Andy Dustman - 2010-02-16

    Based on your other thread, you are using pymysql and not MySQLdb so your
    question can't be answered here with certainty.But no, connect/disconnect is
    not necessary. However, since you are probably depending on transactional
    properties, you need to call cursor.commit() or cursor.rollback()
    appropriately. Executing any SQL query (including SELECT) implicitly starts a
    new transaction. I would say that before you make your query, you should try a
    cursor.rollback(), to make sure there is no pending transaction.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.