LoginSignup
1
0

More than 3 years have passed since last update.

トラブったときに参照した記事一覧:Pytnon編

Last updated at Posted at 2020-03-18

この記事の目的

開発時にトラブってググったけど、再発時に忘れてるということが多いのでトラブルごとに解決に役立った記事をまとめておく

DB接続

カーソル処理をWith句でまとめる
参照先:Python+MySQL でコネクションやカーソルと with 文

from contextlib import closing
with closing(conn.cursor()) as cursor:
    cursor.execute("SELECT * FROM table")
    rows = cursor.fetchall()
    ...
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0