How to Connect to SQL Server with Python | pyodbc Library | Quick Start

preview_player
Показать описание
This is a QUICK START guide for the pyobc Python library for those who use it to connect to Microsoft SQL SERVER.

The topics that I'll cover in this video include:

(1) Setting up a SQL connection string
(2) Create a SQL server database connection
(3) SELECT queries with a single parameter
(4) SELECT queries from multiple parameters
(5) INSERT rows from values
(6) INSERT multiple rows from an iterable object
(7) INSERT multiple rows from another query result
(8) Return table information as a list
(9) Return column information as list

Besides the standard query stuff you would expect... there are A LOT of other things that you can do with pyodbc, with some creativity. For example, you can use it to stage an ETL process...yes, you can execute a python script with a scheduled task on your computer... pretty cool. I often run queries in a FOR loop when I want to process data over multiple periods of time, but it is more efficient to load it in one month or one year increments. The sky is the limit! Enjoy!

The goal of this channel is to help you expand your analytics toolkit. If you find this content helpful, please make sure you hit that LIKE button and SUBSCRIBE to be notified of future videos.
Рекомендации по теме
Комментарии
Автор

Excellent video! This video saved me, and many others it appears, a bunch of time.

carterhenderson
Автор

Thank you so much. This video helped me a lot!

Автор

I am using a dash flask application deployed on azure apps.

I've tried to use close and dispose but it does not close the SPID connection. It just accumulates.

chriskeo
Автор

Very good video! Thank you for sharing

renatocorreaarrieche
Автор

Wonderful !! very informative, thank you for sharing !

janivimal
Автор

Nice video. Clear and to the point. 🚀 Keep growing 🚀🚀

SoumeshRanger
Автор

Thank you so much. This video helped me a lot.

mounikapathuri
Автор

Hi Izzy, I tried your method to connect SQL Server with python and it worked out very well eventually got the result but I have been getting an error when i create a connection,
This Code: conx = pyodbc.connect(conx_string);
I get an error message,

TypeError: argument 1 must be a string or unicode object
it doesn't affect the result but if you could help me with the error i would be grateful thank you

gowthamankamalanathan
Автор

Thank Thank Thank Thank Thank Thank Thank you.... This video saved my life :)

boaretto
Автор

Hi Izzy,
I am trying to connect to remote host sql server located on windows server 2019 using pyodbc. But eventually end up getting an error. Is there any parameter to specify the remote host ip address and connect to sql server present on remote host ? Please advice

surendarsakthivel
Автор

Hey Lizzy,
When i try it on my computer there are several methods which i am not able to view properly,
I dont know what am i missing

rajkumarrajan
Автор

Hey Lizzy,
How can we create a Database in SQL Server?

rajkumarrajan
Автор

Help!!
After importing how to change it to a dataframe

businessdevelopmentstrategies
Автор

I faced an error "Data source name not found and no default driver specified (0) (SQLDriverConnect)".
Could you tell me how to fix that?

convallariamarjalis
Автор

Hey Izzy, thanks for a great video, appreciate you taking the time to publish these for our benefit. I read over the list comprehension docs but I was wondering is there any way to look at the data structure of cursor.columns() so it's a little more intuitive what is being called by row.column_name as row iterates over the cursor.columns()?

JoshuaDHarvey
Автор

hi, can you help me understand how to connect to hive like what changes should i do to connect to hive instead of sql server i presently use hue to access. P.S I am a beginner.

saicigna
Автор

How to connect to the database
using the SSH tunnel with the public key?

tyl
Автор

Hello IZZY, I have such an error: module 'pyodbc' has no attribute 'connect'. Previously I have installed pyodbc on my PyCharm.

maratpopov
Автор

Hey can i insert the JSON data output as values, like they are also a kind of tuples, they are actually a list ! will that work?? but I must say you made a nice video. it was much helping

cmiu
Автор

my drivers list is empty. Can somebody help me?

yasirmalik