• <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

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

            python的pymysql游標(biāo)的使用

            Method MySQLCursor.executemany(operation, seq_params)
            數(shù)據(jù)庫操作operation會執(zhí)行多次,直至seq_params中所有參數(shù)執(zhí)行完畢。
            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()
            返回查詢的結(jié)果集合。
            >>> 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個查詢結(jié)果,如果沒有足夠的結(jié)果,則返回空的list。
            Method MySQLCursor.fetchone()
            返回接下來的一個查詢結(jié)果,該函數(shù)在fetchamany()和fetchalll()中調(diào)用。
            Property MySQLCursor.column_names
            只讀屬性。返回一個Unicode編碼的string,為結(jié)果集合的列名稱。
            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(行號游標(biāo))
             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 閱讀(621) 評論(0)  編輯 收藏 引用 所屬分類: python

            久久综合久久综合久久| 久久人人爽人人爽人人爽| 久久精品国产亚洲77777| 国产精品女同久久久久电影院| 91精品国产91久久久久福利| 亚洲国产精品热久久| 久久久久久无码国产精品中文字幕 | 亚洲精品乱码久久久久久| 久久亚洲私人国产精品| 精品无码久久久久久久动漫| 国产精品久久久久免费a∨| 99久久婷婷免费国产综合精品| 久久精品亚洲精品国产欧美| 久久久久久午夜成人影院| 亚洲成av人片不卡无码久久| 青青青青久久精品国产h| 思思久久99热只有频精品66| 91亚洲国产成人久久精品| 久久久无码精品亚洲日韩按摩 | 久久99精品久久久久久不卡 | 色老头网站久久网| 91久久精品91久久性色| 国产aⅴ激情无码久久| 亚洲欧美一级久久精品| 办公室久久精品| 久久免费高清视频| 人妻无码久久一区二区三区免费| 欧美粉嫩小泬久久久久久久| 国产精品99久久不卡| 91精品国产91久久久久久| 久久综合欧美成人| 国产精品久久久久…| 国产成人无码久久久精品一| 少妇久久久久久被弄高潮| 人妻少妇久久中文字幕一区二区| 国内精品人妻无码久久久影院导航| 久久只这里是精品66| 2020国产成人久久精品| 亚洲综合精品香蕉久久网| 久久99热这里只有精品国产| 成人久久免费网站|