Skip to content
Advertisement

Accessing Microsoft Sharepoint files and data using Python

I am using Microsoft sharepoint. I have an url, by using that url I need to get total data like photos,videos,folders,subfolders,files,posts etc… and I need to store those data in database(Sql server). I am using python.

So,Please anyone suggest me how to do this and I am beginner for accessing sharepoint and working this sort of things.

Advertisement

Answer

Here’s the starter code for connecting to share point through Python and accessing the list of files, folders and individual file contents of Sharepoint as well. You can build on top of this to suit your needs.

Please note that this method works for public Sharepoint sites that are accessible through internet. For Organisation restricted Sharepoint sites that are hosted on a Company’s intranet, I haven’t tested this code out.

You will have to modify the link to the Sharepoint file a bit since you cannot directly access a Sharepoint file in Python using the URL address of that file which is copied from the web browser.

JavaScript

Now that we are able to retrieve and print the list of files present in a particular folder in Sharepoint, below is the code to access the file contents of a particular file and save it to local disk having known the file name and path in Sharepoint.

JavaScript

You can refer to the following links for connecting to SQL server and storing the contents in tables: Connecting to Microsoft SQL server using Python

https://datatofish.com/how-to-connect-python-to-sql-server-using-pyodbc/

Advertisement