Control Transactions in Python-Snowflake Connection

preview_player
Показать описание
In this video , I have discussed how to control Transactions in Python-Snowflake Connection

Prerequisite:
-----------------------
Transaction, Commit and Rollback in Snowflake
Transaction in Stored Procedure in-depth intuition

Snowflake Query:
---------------------------
--drop database if required
drop database if exists ramu;
--Create Database
create database if not exists ramu;
--use the database
use ramu;
create or replace table employee_history(employee_id number,
empl_join_date date,
dept varchar(10),
salary number,
manager_id number);
select * from employee_history;
create or replace table employee_history2(employee_id number,
empl_join_date date,
dept varchar(10),
salary number,
manager_id number);
select * from employee_history2;

Code without transaction control:
-------------------------------------------------------------

user=""
password=""
account=""

statement_1 = 'use warehouse COMPUTE_WH'
statement2 = "alter warehouse COMPUTE_WH resume IF SUSPENDED"
statement3 = "use database RAMU"
statement4 = "use role ACCOUNTADMIN"
statement5 = "use schema PUBLIC"

Code with transaction control:
-------------------------------------------------------------
import pandas as pd

user=""
password=""

statement_1 = 'use warehouse COMPUTE_WH'
statement2 = "alter warehouse COMPUTE_WH resume IF SUSPENDED"
statement3 = "use database RAMU"
statement4 = "use role ACCOUNTADMIN"
statement5 = "use schema PUBLIC"

Check this playlist for more Data Engineering related videos:

Snowflake Complete Course from scratch with End-to-End Project with in-depth explanation--

🙏🙏🙏🙏🙏🙏🙏🙏
YOU JUST NEED TO DO
3 THINGS to support my channel
LIKE
SHARE
&
SUBSCRIBE
TO MY YOUTUBE CHANNEL
Рекомендации по теме
Комментарии
Автор

Hi Bro, Your videos are really useful and they value a TON. I am sure thousands of people are benefitted from your videos. I have a request, Could you please create a video on how to debug a python program while dealing with snowflake. If it is already available, pls direct me to that video. Thanks in advance.

subramanyams
Автор

Exception handling is important for the sessions which is initialized with autocommit=False.. Though the transaction is not partially committed, abrupt closure of session without exception handling will keep the transaction active in background with "HOLDING" Status and blocks any DML actions on the same table until the transaction is timed out..

ashifahamed
Автор

Hi, could you kindly make a video on how to run all these queries in parallel in snowflake using asynchronous execution.

karangupta_DE
Автор

Hi, how do you migrate your python code in pycharm from dev to production environment? Do you use any orchestration tool to run the python script in production? For me, once i have written the code, and after testing by the qa team, i need to copy scripts to production server, and run the main.py from let's say informatica cloud.

karangupta_DE