Access to the database
db = records.Database ( 'mysql: // root:? [email protected]/web_table charset = utf8')
Notes: xxxx is the password data
to perform sql:
= SQL "SELECT * from index_page_table;"
# perform operations database statements
Data = db.query (SQL)
# acquiring a first data line, the data type dict
data = data.first()
# All the data, the data type list
= data.all Data ()
# json data format conversion and to save the file yaml
= data.export json_data ( "yaml")
Print (json_data)
# yaml document which writes data
with Open ( "222.yaml", "W", encoding = "UTF-. 8") AS F:
f.write ( json_data)
# close the connection
f.close ()
Today's share on here, if you want to learn more about what records See " https://www.cnblogs.com/wagyuze "