Rename field in Access DB
Diez B. Roggisch
deets at nospam.web.de
Wed May 14 11:09:34 EDT 2008
Iain King wrote:
> I'm manipulating an MS Access db via ADODB with win32com.client. I
> want to rename a field within a table, but I don't know how to. I
> assume there is a line of SQL which will do it, but nothing I've tried
> (from searching) has worked.
> Basic code:
>
> import win32com.client
> connection = win32com.client.Dispatch(r'ADODB.Connection')
> DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=dbfile.mdb;'
> connection.Open(DSN)
> connection.Execute("ALTER TABLE tablename CHANGE from to") #this sql
> doesn't work
> connection.Close()
>
> Anyone know how to get this to work?
I don't think Access supports SQL on the DDL-side. Try looking into the
Access COM-Api, maybe you can get a reference to the table and modify it.
Diez
More information about the Python-list
mailing list