# Relative movement: it starts to move backward relative to the current position of the cursor # Demonstration of absolute mobility # Absolute move: it starts to move backward relative to the starting position of all data The second parameter is the moving mode, with two values: absolute: absolute, relative: relative Through cursor.scroll (number, mode), the first parameter is an int type number, indicating the number of records to move back. Similarly, we can move the cursor position and continue to take the data in front of us. After each read, the cursor moves to the corresponding position. The operation of fetching data is like reading the contents of a file. As we said above, if our data is fetched once, it will be gone. # When we can create the cursor again, we can cursor Add a parameter: cursor=conn.cursor(cursor=)The result is in dictionary format, fetchall perhaps fetchmany The result is the data form of the list set dictionary # cursor=conn.cursor(cursor=) #Get the result represented by dictionary data type: Otherwise, there will be confusionĬonn=nnect(host= ' localhost ',port=3306,user= ' root ',password= ' 123 ',database= ' student ',charset= ' utf8 ') # Specify code as utf8 When I was there, I didn't notice-,Do not write utf-8,Database forĬursor=conn.cursor() # That's what I think mysql The cursor of the client mysql> Enter the command after this, enter to execute You need to specify which database you operate, the name of the database, and the character set. # Links, specifying ip Address and port, when testing on this machine ip Address can be written localhost Or your own ip Address or 127.0.0.1,Then you need to specify the user name and password when you operate the database. In essence, it is a socket client, but this socket client is used in python program # install, Execute the following code in the command line window
How to operate mysql in python program? It is the same as the client with mysql and navicat.