作为主题,这是代码,没有错误消息,但没有插入数据。这是我的代码,谁能告诉我它有什么问题?
import psycopg2
import sys
import os
import glob
import csv
#open the csv folder
dictfile='******'
os.chdir(dictfile)
total=[]
for file in glob.glob("*.csv"):
total.append(file)
con = None
try:
con = psycopg2.connect(host='localhost',database='*****',user='postgres', password='*****')
cur = con.cursor()
for i in range(0,1):
filename='/Users/Shared'+'/'+total[0]
print filename
#better move all files into shared folder
x="copy public.crossref_sample from "+ "'"+filename+"'"+" DELIMITERS ',' CSV"
print x
cur.execute(x)
except psycopg2.DatabaseError, e:
print 'Error %s' % e
sys.exit(1)
finally:
if con:
con.close()