python + database

  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.
  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.

ในpython มี db api หลายๆ ตัว โดยแต่ละตัวจะมี ฟังชั่นดังนี้ .fetchone() .fetchall() .fetchmany() อยากทราบว่าไอ้ fetchall() กับ fetchmany() มันต่่างกันอย่างไรครับ

อันนี้ อาจจะได้คำตอบหรือเปล่าครับ

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/137270

แต่ก็ขึ้นอยู่กับ implementation ของ api แต่ละตัวด้วยนะครับ ว่าเค้า optimize กับการ fetch แค่ไหน บางอัน fetchmany ก็แค่เรียก fetchone วนลูปเอา

sugree's picture

ต้องอ้าง PEP http://www.python.org/dev/peps/pep-0249/

  • fetchmany จะให้ระบุจำนวนมากสุด
  • fetchall คือเอาทั้งหมดที่เหลือ
khao_lek's picture

ขอบคุณครับ

ย้าย Codenone

ประกาศย้าย Codenone ไปใช้ Forum ของ Blognone แทนครับ ตามไปตั้งกระทู้ต่อได้ที่ Codenone Forum (รายละเอียดอ่านจากกระทู้ ย้าย Codenone ไปรวมกับ Blognone)

กระทู้เก่าๆ จะย้ายตามไปในภายหลัง ตอนนี้ปิดการโพสต์กระทู้ไว้ เหลือไว้เฉพาะอ้างอิงเท่านั้น