开发者

How can I use Django to store a table of data into MySQL?

开发者 https://www.devze.com 2023-04-10 13:18 出处:网络
I am parsing a HTML file to pull down attributes for a list of cell phones.What is the best way to store this data in Python/Django so I can save each cell phone as a record in MySQL?

I am parsing a HTML file to pull down attributes for a list of cell phones. What is the best way to store this data in Python/Django so I can save each cell phone as a record in MySQL?

In other words, if I have data that looks like this:

NAME ATTRIBUTE-A ATTRIBUTE-B ATTRIBUTE-C

iPhone 3 Hours 4 Hours 5 Hours

evo 4G 2 Hours 3 Hours 4 Hours

How should I be storing this in Python and then exporting it to my DB in MySQL开发者_高级运维?


Create a model that matches your data. Parse your data (method will vary by if your data is json, xml, csv, xls, etc, etc). Set model fields to your data values and save.

You should read up on models (Django Models) for more information on how a django project interacts with databases

0

精彩评论

暂无评论...
验证码 换一张
取 消