''' link database create table ''' import pymysql # create connection conn = pymysql.connect(host="192.168.4.1",port=1036,db="test",username="",password="") # create cursor cus = conn.cursor() sql = "select * from test;" ''' # implement cus.execute(sql) #Get all results, before getting results cus.fetchall() # get a result cus.fetchone () # Take 10 rows of data cus.fetchmany(size=10) #submit cus.commit() # close the cursor cus.close() cus.executemany() ''' try: cus.execute(sql) result = cus.fetchone() print(result) except Exception as e: raise e finally: # so that it can be closed no matter what cus.close() conn.close() ''' update insert create table table_name (id int not null); create table %s (%s) [(a1, id int not null) , (b2, name string) ] The format of the string is similar ''' ''' id name age a = Student(id=, name=, age=) a.save() insert filter(id=100) ''' ''' create table 表名( column name data type not null ); create table Student( StdID int not null, StdName varchar(100), Gender enum('M','F'), Age tinyint ); '123' varchar(10) '123 ' char(10) ''' ''' show databases; show tables; show variables like '%auto%'; show full processlist # Authorize super permissions grant all privileges on *.* to 'username'@'%' identified by "123456" with grant option; Skip-grant-talbes '''
Link database creation table for python notes
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325944175&siteId=291194637
Ranking