开发者

How can I use Django to store a table of data into 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜