How to call python script in SnapLogic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2020 01:43 AM
Hi Team,
I need to call below sample python script from snaplogic.
or is there a way to call .py file in snaplogic
import pandas as pd
################Can be snap logic pipeline###############333333
import pyodbc
conn = pyodbc.connect(‘DRIVER={ODBC Driver 13 for SQL Server};
SERVER=ps-sql; database=test; trusted_connection=yes’)
sql = ‘’’
select * from temp
‘’’
df = pd.read_sql(sql, conn)
######################################################33
#######################Feed SQL into python######################3
import pandas as pd
longform = pd.DataFrame(columns=[‘assets__c’, ‘id’])
for idx, songs, name in df.itertuples():
name_words = (i.lower() for i in name.split())
longform = longform.append(
[{‘assets__c’: nw, ‘id’: songs} for nw in name_words],
ignore_index=True
)
longform[‘refreshdate_unpack’] = pd.to_datetime(‘today’)
longform
##############Write longform into a sql table######################
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2020 01:40 AM
any inputs?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2020 02:27 AM
Hi,
There are a couple of Snaps you can use:
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1439321/Script
or
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/615383126/Remote+Python+Script
Though the Remote Python Script takes a bit more doing to get it going.
BR,
Dimitri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2020 01:42 AM
How Can I get the The hostname of Remote Python Executor.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2020 03:52 AM
@sanam Hello again! I replied on your separate thread about the RPE hostname (Remote Python Snap Account). What I want to add to this thread is that if you need a third-party Python library the Remote Python Script snap is the way to go and the RPE images we maintain already have Pandas.
From a design perspective, is there a reason your thinking about making the SQL connection in Python rather than using the SQL Server snap pack for the read, then passing the data into the RPE snap for processing with Pandas?