简体   繁体   中英

Altered Table not adding Column (pymssql)

I am using pymssql and i have a very simple add column statement. When i run the statement i get no error. If i run the same statement that i print out, in ms sql management studio, the column gets added.

table = 'tableName'
cmd = 'ALTER TABLE ' + table + ' ADD temp FLOAT NULL'
print(cmd)
cursor.execute(cmd)

pymssql does not automatically commit every statement you run.

Connection.commit()

Commit current transaction. You must call this method to persist your data if you leave autocommit at its default value, which is False.

http://pymssql.org/en/stable/ref/pymssql.html#connection-object-methods

So the ALTER TABLE is probably getting rolled back when your program ends.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM