In this python video I will be discussing how to connect to a SQL server and run a simple query
Music by Bensound, www.bensound.com
----Code snippet---------
import dbconfigs as db
import pyodbc
cn1 = pyodbc.connect (r'DRIVER=SQL Server;'
f'server={db.SEVERNAME};'
r'Database=master;'
f'User ID={db.USER};'
f'password={db.PASSWORD}'
)
qry = 'SELECT name from sys.databases'
csr = cn1.cursor()
csr.execute(qry)
dbnames = csr.fetchall()
print(dbnames)
for name in dbnames:
print(name[0])
On this page of the site you can watch the video online Connecting to SQL Server with Python - Python programming for beginners with a duration of hours minute second in good quality, which was uploaded by the user Brendan Callaghan 09 March 2023, share the link with friends and acquaintances, this video has already been watched 794 times on youtube and it was liked by 5 viewers. Enjoy your viewing!