pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.94k stars 18.04k forks source link

write_frame fails to replace table (io.sql) #4033

Closed jhubele closed 11 years ago

jhubele commented 11 years ago

For the option if_exists='replace' in write_frame the table is dropped but not re-created. Simple error in the logic:

#create or drop-recreate if necessary
create = None
if exists and if_exists == 'replace':
    create = "DROP TABLE %s" % name
elif not exists:
    create = get_schema(frame, name, flavor)

if create is not None:
    cur = con.cursor()
    cur.execute(create)
    cur.close()
jreback commented 11 years ago

closing in favor of #2971