• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Benjamin

            靜以修身,儉以養德,非澹薄無以明志,非寧靜無以致遠。
            隨筆 - 397, 文章 - 0, 評論 - 196, 引用 - 0
            數據加載中……

            python的pymysql游標的使用

            Method MySQLCursor.executemany(operation, seq_params)
            數據庫操作operation會執行多次,直至seq_params中所有參數執行完畢。
            data = [
            ('Jane', date(2005, 2, 12)),
            ('Joe', date(2006, 5, 23)),
            ('John', date(2010, 10, 3)),
            ]
            stmt = "INSERT INTO employees (first_name, hire_date) VALUES (%s, %s)"
            cursor.executemany(stmt, data)
            Method MySQLCursor.fetchall()
            返回查詢的結果集合。
            >>> cursor.execute("SELECT * FROM employees ORDER BY emp_no")
            >>> head_rows = cursor.fetchmany(size=2)
            >>> remaining_rows = cursor.fetchall()
            Method MySQLCursor.fetchmany(size=1)
            返回接下來的size個查詢結果,如果沒有足夠的結果,則返回空的list。
            Method MySQLCursor.fetchone()
            返回接下來的一個查詢結果,該函數在fetchamany()和fetchalll()中調用。
            Property MySQLCursor.column_names
            只讀屬性。返回一個Unicode編碼的string,為結果集合的列名稱。
            cursor.execute("SELECT last_name, first_name, hire_date "
            "FROM employees WHERE emp_no = %s", (123,))
            row = dict(zip(cursor.column_names, cursor.fetchone())
            print("{last_name}, {first_name}: {hire_date}".format(row))
            cursor.MySQLCursorDict Class用法(繼承自MySQLCursor,返回每行的字典)
            cnx = mysql.connector.connect(database='world')
            cursor = cnx.cursor(dictionary=True)
            cursor.execute("SELECT * FROM country WHERE Continent = 'Europe'")
            print("Countries in Europe:")
            for row in cursor:
                print("* {Name}".format(Name=row['Name']
            也可以通過format來訪問    
            cursor.execute("SELECT Name, Population FROM country WHERE Continent = 'Europe'")
            print("Countries in Europe with population:")
            for row in cursor:
                print("* {Name}: {Population}".format(**row))
                
                
                
             cursor.MySQLCursorRaw Class(行號游標)
             import mysql.connector
            cnx = mysql.connector.connect()
            # Only this particular cursor will be raw
            cursor = cnx.cursor(raw=True)
            # All cursors created from cnx2 will be raw by default
            cnx2 = mysql.connector.connect(raw=True)
            cursor.MySQLCursorNamedTuple(行元組)
            cnx = mysql.connector.connect(database='world')
            cursor = cnx.cursor(named_tuple=True)
            cursor.execute("SELECT * FROM country WHERE Continent = 'Europe'")
            print("Countries in Europe with population:")
            for row in cursor:
                print("* {Name}: {Population}".format(
                    Name=row.Name,
                    Population=row.Population
                ))

            posted on 2020-05-09 16:01 Benjamin 閱讀(616) 評論(0)  編輯 收藏 引用 所屬分類: python

            国产成人无码精品久久久久免费| 久久综合给久久狠狠97色| 欧美久久综合性欧美| 亚洲国产精品久久久久久| 国产精品成人99久久久久| 日本久久久久久久久久| 久久中文字幕人妻丝袜| 久久精品无码一区二区三区| 久久综合久久鬼色| 三上悠亚久久精品| 久久久亚洲精品蜜桃臀| 国产麻豆精品久久一二三| 亚洲国产成人久久综合一区77| 久久综合给合久久狠狠狠97色69| 久久久久国色AV免费看图片| 久久婷婷五月综合色奶水99啪| 久久国产精品免费一区| 国产精品美女久久久久久2018| 狠狠色丁香久久婷婷综合_中 | 久久av高潮av无码av喷吹| 漂亮人妻被中出中文字幕久久 | 综合久久给合久久狠狠狠97色| 久久亚洲精品无码AV红樱桃| 国产69精品久久久久观看软件| 天天久久狠狠色综合| 97久久久久人妻精品专区| 亚洲精品国产字幕久久不卡| 性做久久久久久久久久久| 97精品伊人久久久大香线蕉| 久久久精品人妻一区二区三区蜜桃 | 久久九色综合九色99伊人| 国产精品久久永久免费| 99久久精品日本一区二区免费| 97精品伊人久久久大香线蕉| 漂亮人妻被中出中文字幕久久 | 久久综合九色综合欧美狠狠| 国产成人久久激情91| 精品综合久久久久久97超人 | 国产精品美女久久久久AV福利| 久久综合综合久久97色| 91精品国产91久久久久久蜜臀|