在python数据库中插入json数据

qaxu7uf2  于 2021-06-24  发布在  Mysql
关注(0)|答案(2)|浏览(473)

我目前正在做一个系统,从foursquare中删除数据。现在,我已经从使用python和beautiful soup的网站上删除了评论,并有一个json文件,如下所示

{"review": "From sunset too variety food u cant liked it.."}{"review": "Byk motor laju2"}{"review": "Good place to chill"}{"review": "If you wan to play bubble and take photo, here is the best place"}{"review": "Scenic view for weekend getaway... coconut shake not taste as original klebang coconut shake..."}{"review": "Getting dirtier"}{"review": "Weekend getaway!"}{"review": "Good for casual walk & watching sunset with loved ones since my last visit macam2 ade kat sini very packed during public holidays"}{"review": "Afternoon time quite dry..beach is normal. Maybe evening/night might be better. The coconut shake they add vanilla ice cream,hmmm"}{"review": "Pantai awesome beb"}{"review": "Nice place for picnic"}{"review": "Cannot mandi here. Good place for recreation.. Calm place for weekdays! Haha"}{"review": "Very bz place. Need to go there early if you want to lepak. If not, no parking for you"}{"review": "So many good attraction here, worth a visit"}{"review": "Beautiful place for sunset"}{"review": "New beach!  Like all beaches, awesome view & windy.  Some stretch got many small crabs."}{"review": "There is bustel \"hotel in a bus\" can get coconut shake or fried seafood in the evening at 5pm. Bustel rate is from RM80. Bus cafe, bus toilet... Total bus transformation"}{"review": "Too crowded la"}{"review": "Muzium kapal selam closed since 1/3 until further notice..\ud83d\ude29"}{"review": "If you are looking for public toilets, look for a red bus. An old bus was modified and transformed to operate as toilets. Cool."}{"review": "Most of the shops closed after 12 midnight..helloo,this place should be the place for the late nighters..late night supposed to be the peak hour for business..live band bar maybe?? :-P"}

我的问题是如何立即将数据插入数据库?是mysql可以使用,还是我应该改用Pymango。

yiytaume

yiytaume1#

这取决于你的习惯。基本上,mongodb适合于json文档,所以您可以“直接”插入python对象。如果您想/需要使用mysql,则可能需要在插入之前执行一些转换。查看本文了解更多信息:使用python将json插入mysql

3vpjnl9f

3vpjnl9f2#

您可以将json转换为字符串(json.dumps())并存储在字符字段中。
或者,django在使用postgres(docs)时支持jsonfield,这有一些额外的特性,比如在json内部查询

相关问题