![making sql database for python in visual studio code making sql database for python in visual studio code](https://devblogs.microsoft.com/python/wp-content/uploads/sites/12/2019/06/June19-PlotViewer-1024x565.gif)
You can create a new environment for each project to keep things well organized. This way it does not affect any other projects. The drivers and modules inside our environment will only be available to this project. It will choose the system default version but we want to setup an environment to work within first. When you open a file with the extension of *.py you should see VS Code recognize this and display the Python version it is using in the bottom left corner. Note: If you get stuck in a python shell just type “exit()” to get back to the terminal. Then open the terminal using “Terminal -> New Terminal”.Ĭheck that the python version is correct by typing: python -V Start by creating a new folder and a new file called “main.py”, open “main.py” in Visual Studio code. We need to create an environment to work in.
![making sql database for python in visual studio code making sql database for python in visual studio code](https://www.sourcecodester.com/sites/default/files/sql11.png)
import pyodbcĬursor.execute("SELECT TOP(1000) * FROM sometable") The important parameter is where the “ username and password” were set, we are replacing it with “Trusted_Connection=yes” so the user account logged into Windows is used instead. SQL Server (version should be 2012 or later).
MAKING SQL DATABASE FOR PYTHON IN VISUAL STUDIO CODE INSTALL
We will setup a Python environment and install the module needed to connect to SQL Server using the currently logged in Windows user. This is also similar to our recent post on connecting to MySQL using Visual Studio code in Linux and this post has more info on the Python extension if you do not have them installed. For this example we will be connecting to a SQL Server database using the Visual Studio Code ( VS CODE), Windows Authentication and the pyodbc module.