1
我有一個Postgres的表結構如下插入數據3.4
CREATE TABLE edmonton.permit
(permit_date text,
permit_number text,
year numeric,
month_number integer,
report_permit_date text,
job_category text,
address text,
legal_description text,
neighbourhood text,
neighbourhood_number text,
job_description text,
building_type text,
work_type text,
floor_area numeric,
construction_value integer,
zoning text,
units_added numeric,
latitude double precision,
longitude double precision,
location text,
count integer
我想讀一個相對路徑和導入數據的csv文件到Postgres的表像之下
with open(file) as f:
reader = csv.reader(f, delimiter=',')
next(reader, None)
for row in reader:
cur.execute("INSERT INTO edmonton.{}(permit_date, permit_number, year, month_number, report_permit_date, job_category, address, legal_description, neighbourhood, neighbourhood_number, job_description, building_type, work_type, floor_area, construction_value, zoning, units_added, latitude, longitude, location, count) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)".format(permit),row)
con.commit()
我提示以下錯誤:
Invalid literals for numeric datatype.
什麼地方持有人應用於數字,整數,雙精度使用python3.4?
對於Psycopg的所有內容,佔位符均爲'%s'。您需要顯示csv。 –