# DBT cloud python script execute

**URL:** <https://discourse.getdbt.com/t/dbt-cloud-python-script-execute/8099>\
**Category:** Help\
**Created:** [May 1, 2023, 8:52pm UTC](https://discourse.getdbt.com/t/dbt-cloud-python-script-execute/8099 "2023-05-01T20:52:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skota](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@skota](https://discourse.getdbt.com/u/skota)\
**Post date:** [May 1, 2023, 8:52pm UTC](https://discourse.getdbt.com/t/dbt-cloud-python-script-execute/8099/1 "2023-05-01T20:52:49Z")

</div>

from urllib.parse import quote\_plus as urlquote  
from snowflake.connector.pandas\_tools import pd\_writer  
from sqlalchemy import create\_engine  
import logging  
import requests  
import pandas as pd  
from datetime import datetime

# Set Snowflake connection parameters

user = ‘your\_user\_name’  
password = ‘your\_password’  
database = ‘your\_database\_name’  
warehouse = ‘your\_warehouse\_name’  
account = ‘your\_account\_name’  
role = ‘your\_role\_name’

conn\_string = f’snowflake://{user}:{urlquote(password)}@{account}/{database}?warehouse={warehouse}&role={role}’

# Create a connection to Snowflake

engine = create\_engine(conn\_string)  
with engine.connect() as con:  
print(‘connected’)

```
# Get data from xml and convert to dataframe
r = requests.get('https://rp.railcl.com/RAILPort/report/data/28e3d782-e0ca-4e19-8573-09002e8e9c69?p=e')
df_railtrac = pd.read_xml(r.content)

# Fix column names and push to Snowflake with the load_date field
fix_cols = [col.lower().replace('_x0020','').replace('x002f','').replace('.','') for col in df_railtrac.columns]
print(fix_cols)
df_railtrac.columns = fix_cols
df_railtrac['load_date'] = datetime.now()

df_railtrac.to_sql(name='s_railtrac_livelink', con=con, if_exists='append', index=False)

```

I am executing this script using Jupyter notebook load xml data. is it possible to implement same in dbt cloud python
