我是靠谱客的博主 粗心花瓣,这篇文章主要介绍python获取mysql表中一列数据_将Python列表插入mySQL数据库中的一列,现在分享给大家,希望可以做个参考。

嗨,我试图在一列中插入一个python列表,但是它总是在语法上给出错误。

这是新手。谢谢你的帮助。谢谢。在from time import time

import MySQLdb

import urllib

import re

from bs4 import BeautifulSoup

db = MySQLdb.connect("localhost","testuser","test123","testdb" )

cursor = db.cursor()

x=1

while x<2:

url = "http://search.insing.com/ts/food-drink/bars-pubs/bars-pubs?page=" +str(x)

htmlfile = urllib.urlopen(url)

soup = BeautifulSoup(htmlfile)

reshtml = [h3.a for h3 in soup.find("div", "results").find_all("h3")]

reslist = []

for item in reshtml:

res = item.text.encode('ascii', 'ignore')

reslist.append(' '.join(res.split()))

sql = "INSERT INTO insing(name)

VALUES %r"

% res

最后

以上就是粗心花瓣最近收集整理的关于python获取mysql表中一列数据_将Python列表插入mySQL数据库中的一列的全部内容,更多相关python获取mysql表中一列数据_将Python列表插入mySQL数据库中内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部