![sql error 18456 using sa account sql error 18456 using sa account](https://i0.wp.com/www.csharp-console-examples.com/wp-content/uploads/2018/05/sql-18456-step1.jpg)
I resolved this by doing the following on the SQL Server 2005: Open SQL Server Management Studio. Also there's no reason to do del connection because it's not like that object is taking up any memory. In my case, the message was 'Error: 18456 Severity: 14 State: 16'. Reset the SA account’s password (if this is the first time it has been used, it may be blank already) 1. Type this where it displays 1> ALTER LOGIN sa ENABLE. And if you handle your commits/transactions in sql you don't need to worry about batching the executions in python. In the command prompt type: osql -S TheNameOfYourSQLServer -E. An Engine object does not actually establish a connection but doing something like engine.execute(sql) will open the connection and execute the statement and close the connection but leave your engine object available for more if you want. Also there's some unnecessary connection shit you're doing with sql alchemy. What seems to be happening is you aren't closing that connection properly and it's opening a new one causing SQL to lock sa for whatever reason. I would control your transaction blocks in SQL instead of in python. You don't want to be using the sa account from an external application, even if it's just a python script.
#Sql error 18456 using sa account full#
Create that login in sql and give it just the permissions it needs, not full blown sys admin - we do this through a dba role we created. If you are a windows org, have your sys admin create an AD group called something like domain\DBA and have them add yourself and whoever else to it. First paragraph is optional and unrelated to the actual issue "because we've always done it" is my absolute least favorite thing to hear in the IT world.
![sql error 18456 using sa account sql error 18456 using sa account](https://www.nextofwindows.com/wp-content/uploads/2014/05/2014-05-28_1318_thumb1.png)
The reason i use sa is because people in my group all have have been using it for years and i rather keep things as is