Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Snowflake integration with Sharepoint

Hi I'm trying to integrate Snowflake with Sharepoint. We want to write the data from Snowflake into Sharepoint files and vice versa. Read the data from sharepoint files and load into Snowflake using Python.

We are not looking to use a separate integration tool. We have Python used to integrate other source systems & looking to continue the same. Looking for some references or sample use cases

like image 315
Siva Meda Avatar asked Jan 23 '26 05:01

Siva Meda


1 Answers

Yes it is possible through Python. Here is a python code that helped me with the same requirement. I am uploading the snowflake query result as a json file to sharepoint

##Getting Imports
from snowflake.sqlalchemy import URL
from shareplum import Office365
from shareplum import Site
from shareplum.site import Version
import pandas as pd
import json
import snowflake.connector


##Connecting to snowflake
con_var = snowflake.connector.connect(
   user = 'your_username',
   password = 'your_password',
   account = 'account_name',
   warehouse = 'snowflake_warehouse',
   database = 'database_name',
   schema = 'schema_type'
)

## Connecting to sharepoint
server_url = "https://yourlink.sharepoint.com/"
site_url = server_url + "sites/your_site_name"
Username = "sp_userid"
Password = "sp_password"

sql_stmt = """ select * from "DB".table_name """

##Writing query result to sharepoint
authcookie = Office365(server_url, username = Username, password=Password).GetCookies()
site = Site(site_url, version=Version.v365, authcookie=authcookie)
folder = site.Folder('Shared Documents/Your_Folder')

df = pd.read_sql(sql_stmt,con_var)
folder.upload_file(df.to_json(orient='records'),'out_file.json')
like image 163
Rajalakshmi Avatar answered Jan 25 '26 18:01

Rajalakshmi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!