For beginners, use pymysql to query the database. I hope I can get the data according to the field name of the database. For example, how to change r [0] to r ['id']?

users = []
            data = {}
            for r in results:
                user = {}
                -sharp user["select_id"] = r[0]
                -sharp user["media_id"] = r[1]
                -sharp user["user_id"] = r[2]
                -sharp user["media_url_or_path"] = r[3]
                -sharp user["media_title"] = r[4]
                -sharp user["media_source"] = r[5]
                -sharp user["created"] = r[6].strftime("%Y-%m-%d %H:%M:%S")
                -sharp user["updated"] = r[7].strftime("%Y-%m-%d %H:%M:%S")
                -sharp user["status"] = r[8]
                -sharp user["is_del"] = r[9]

                user["id"] = r[0]
                user["title"] = r[4]
                user["fingerprint"] = "abc"
                user["create_time"] = r[6].strftime("%Y-%m-%d %H:%M:%S")
                user["status"] = ""
                users.append(user)
Apr.02,2021

my own method is to add individual names to the fields of the query

https://github.com/eastossifr.

this is a project I maintain that uses sqlalchemy to manipulate the database. You can use this project to practice and connect directly to my presentation database.

sqlalchemy this library, if you can use it, it will improve your Python skills qualitatively.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e43e8a-442b2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e43e8a-442b2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?