mysql导入.csv权限拒绝_将csv文件插入mysql表OSError:[Errno 13]权限被拒绝

在尝试使用subprocess调用ringo.py脚本将CSV文件导入MySQL时遇到了权限拒绝错误。代码中,通过os模块进行文件操作,包括重命名和检查文件修改时间。当执行回调函数ringoCallback3时,遇到了问题,导致OSError: [Errno 13]权限被拒绝。
摘要由CSDN通过智能技术生成

我正在尝试使用sub将csv文件插入mysql表进程调用我不知道哪里出错了,我检查了我的文件,一切都很好。在def ringoCallback3(filename):

#Run the RINGO insert script

tmp = filename.split('/')

just_filename = tmp[-1]

new_filename = "/home/toor/doneringofiles/%s" % just_filename

retval = subprocess.call(["/usr/local/bin/ringo.py",filename])

os.rename(filename, new_filename)

return retval

dirlist = [ ['/home/toor/ringolist',ringoCallback3]]

while (True):

# Go through each of the directories

for mylist in dirlist:

check_dir = mylist[0]

callback = mylist[1]

# get the list of files in the directory

filelist = os.listdir(check_dir)

for this_file in filelist:

if ((this_file == ".") or (this_file == "..") or (this_file == "doneringofiles")):

print "Skipping self and parent"

continue

full_filename = "%s/%s" % (check_dir, this_file)

# Get the modification time of the file

first_stat = os.stat(full_filename)[8]

# Sleep for 1 second

time.sleep(1)

# Get the modification time again

second_stat = os.stat(full_filename)[8]

# If the modication time has not changed, then the file is stable

# and can be sent to the callback

if (first_stat == second_stat):

callback(full_filename)

# Now sleep for 30 seconds before doing the whole lot again

time.sleep(30)

当我运行这个代码时:我得到这个错误:

^{pr2}$

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值