Pycharm's python code to access MS SQL database
Hi
I can connect to the Microsoft SQL database in pycharm. I can use the console from pycharm to query. But I have no idea how to connect to the database, query and read into pandas dataframe in pycharm.
Could you provide a sample code?
Thanks
Please sign in to leave a comment.
Hi, you need a python library that supports your specific database. For MS SQL, consider official MS documentation: https://docs.microsoft.com/en-us/sql/connect/python/python-driver-for-sql-server?view=sql-server-ver15
It doesn't really seem like a PyCharm question. Have you looked into pyodbc and SQL alchemy?
The following works for me: