def test_job():
cnxn = pyodbc.connect(r'Driver=SQL Server;Server=*******;Database=( *****;UID=******;PWD=********;Trusted_Connection=Yes;')
todays_date = datetime.datetime.now().date().strftime ("%d-%m-%Y")
MARCH_DATASET=pd.read_sql_query('select * FROM MARCH_2021',cnxn)
todays_file=MARCH_DATASET[MARCH_DATASET.UPLOADED_DATE_CST==todays_date]
Asked
Active
Viewed 90 times
0

Andrzej Sydor
- 1,373
- 4
- 13
- 28
-
If you give trusted connection, you don't need to give a name and a password as trusted means to take it from windows credentials manager. If you still want to do it, you should write in the `User Id=` and not `uid=`. and also pwd is wrong. Your connection string looks like MySQL. You can see it here https://www.connectionstrings.com/sql-server/. `Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;` – The Fool Mar 28 '21 at 08:08
-
@TheFool - Your advice re: `Trusted_Connection=yes` is correct, but `UID` and `PWD` are in fact the correct parameter names as noted [here](https://www.connectionstrings.com/microsoft-odbc-driver-17-for-sql-server/). – Gord Thompson Mar 28 '21 at 11:35
-
@GordThompson after doing some web search, I see that both are valid. Your string is for ODBC and my one is for sqlClient DataProvider. So It would depend on which driver the library is using. https://stackoverflow.com/questions/937083/when-should-i-be-using-odbc-oledb-sqlclient-what-are-the-trade-offs – The Fool Mar 28 '21 at 13:34
-
1Well ok, its saying pyODBC so guess, in this case you are right. – The Fool Mar 28 '21 at 13:36