Skip to main content

python-sharepoint

A Python library and command-line utility for gettting data out of SharePoint.

If you’re more a Perl person, you might also want to try SharePerltopus.

Installation

Either install the latest development from git:

$ git clone git://github.com/ox-it/python-sharepoint.git
$ cd python-sharepoint
$ sudo python setup.py install

… or, install the latest stable version using pip:

$ pip install sharepoint

You will need lxml, which you can install using your package manager or pip. Run one of the following if it’s not already installed:

$ sudo apt-get install python-lxml  # Debian, Ubuntu
$ sudo yum install python-lxml      # RedHat, Fedora
$ sudo pip install lxml             # pip

Usage

First, you need to create a SharePointSite object. We’ll assume you’re using basic auth; if you’re not, you’ll need to create an appropriate urllib2 Opener yourself.

from sharepoint import SharePointSite, basic_auth_opener

server_url = "http://sharepoint.example.org/"
site_url = server_url + "sites/foo/bar"

opener = basic_auth_opener(server_url, "username", "password")

site = SharePointSite(site_url, opener)

Lists

First, get a list of SharePoint lists available:

for sp_list in site.lists:
    print sp_list.id, sp_list.meta['Title']

You can look up lists by ID, or by name:

# By ID, without braces
print site.lists['1EF5668C-0AB4-4020-98EF-26325E412C3C']
# By ID, with braces
print site.lists['1EF5668C-0AB4-4020-98EF-26325E412C3C']
# By name
print site.lists['ListName']

Given a list, you can iterate over its rows:

sp_list = site.lists['ListName']
for row in sp_list.rows:
    print row.id, row.FieldName

It’s not yet possible to modify lists using this library.

Command-line utility

Here’s how to get a list of lists from a SharePoint site:

$ sharepoint lists -s http://sharepoint.example.org/sites/foo/bar \
             -u username -p password

And here’s how to get an entire list as XML:

$ sharepoint -s http://sharepoint.example.org/sites/foo/bar \
             -l ListName \
             -u username -p password

You can also specify a file containing username and password in the format ‘username:password’:

$ sharepoint --credentials=path/to/credentials [...]

For help (including to see more options to configure the output, use -h:

$ sharepoint -h

Metadata

Release files for sharepoint 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sharepoint 0.3
File Size Uploaded Provenance
sharepoint-0.3.tar.gz 12.7 kB Without provenance Details

Release files / sharepoint-0.3.tar.gz

Download URL sharepoint-0.3.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9b11abea45b5622939b55cfa8a351d4927a400fbd224e3ea37580bef17419260
BLAKE2b-256 checksum
How to use checksums
6c2e71f98b5640307fc83b1bb9a0944f5f20f252f8aaec465dcc04ba7b8cd139
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for sharepoint 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page