1

I am using Access and Sharepoint 2010. I am writing a python script, which periodically reads tables, checks some conditions, and eventually writes e-mail notifications. I do not have permission to access the Sharepoint server directly. Also [1]:

Directly interacting with a SharePoint content database will cause your SharePoint installation to lose Microsoft support.

The simplest solution for now would be to download the database through access, but first, I don't know how to do this programatically. Second, when extending my application I might need to update Database as well.

So my best bet seems to be using SOAP. When I use Access to publish a simple table to Sharepoint [2], afaik I can read and write it through Sharepoints SOAP API provided by .../_vti_bin/Lists.asmx [3]. I can see in All Site Content that the table is a ListNode (when I hover over the link with the mousepointer, I can see the javascript function that gets called with the parameters containing "...Listnode..."). But when I publish a more complex database from Access, an accdb with forms, it is a WebNode instead of a Listnode. When I select it in All Site Content, I can click on Options->Settings where I get a list of the tables of the published database. How can I access a particular table from this list from my python script through SOAP? An example would be much appriciated.

So far I got this:

from suds import WebFault
from suds.client import *
from suds.transport.https import WindowsHttpAuthenticated # for https authentification

USER = r'Domain\02345434' #the number is the user id
PWD = 'secret'
#My guess is that you need webs.asmx for accessing WebNodes instead of ListNodes
URL = 'https://mysite.sharepointserver.com/_vti_bin/webs.asmx?WSML'

ntml = WindowsHttpAuthenticated(username=USER, password=PWD)
client = Client(URL, transport=ntml, timeout=200, cache=None)
#try to get some info
#http://msdn.microsoft.com/en-us/library/webs.webs.getwebcollection%28v=office.12%29.aspx
print client.service.GetWebCollection() #fails with SaxParseException: <unknown>:1:0:syntax error

[1] How to Remotely Access SharePoint Database

[2] http://blogs.technet.com/b/hub/archive/2010/11/08/publish-your-access-database-to-sharepoint.aspx

[3] http://www.developer.com/tech/article.php/3104621/SharePoint-and-Web-Services.htm

  • I just read about Sharepoint Designer, which can create workflows. So if it can periodically check a condition in a table, this might be the way to go. If I come to a conclusion, I will post the solution. – phobic Sep 19 '13 at 13:25
  • It is hard for me to obtain the priviledges to access Sharepoint with Sharepoint Designer. So I would appreciate any help with the original approach. – phobic Sep 26 '13 at 14:10
  • It has been a while, and still lacking an answer to my question, I opened another thread at a microsoft website: social.technet.microsoft.com/Forums/sharepoint/en-US/… – phobic Oct 1 '13 at 23:02
1

When you publish an access database to sharepoint, it creates a new web and then creates the various tables in Access as lists under that web. to access that data, you need to change the URL to the web service to include this web. For example, if you published a CUSTOMER database, the URL to access the data would be :

sharepointserver.com/CUSTOMER/_vti_bin/webs.asmx

1

Here are some python code examples to access the database, as I would have needed them when asking the question. First, you can use haufe.sharepoint module. There is no support for the module anymore, but it works: https://pypi.python.org/pypi/haufe.sharepoint It uses ntlm for authentification. The code below also demonstrates how to convert the date string to a date:

from haufe.sharepoint import Connector
import datetime
# URL of the database in sharepoint
SP_URL = 'https://mysite.sharepointsite.com/personal/dom_2348890/A_Test' 
SP_USER = r'DOM\2348890'
SP_PWD = 'secret'
""" Identifier for the table inside the sharepoint database.
The Id can be obtained like this:
1. Get to All Site Collections page on the account that uploaded the database 
2. Unfold the published accdb Acess database so that you can see its tables below
3. Move the mouse over a table ; the link displayed at the bottom of the browser looks like this:
javascript:_spNavigateHierarchy(this,'','30:ListNode:3558b4e7-d150-414f-a001-927b27a331dc:f2c42f06-54fe-4242-8fab-54fbod191f9c:e014b7d4-f2b5-4141-adc9-55cf930d557d','\u002fpersonal\u002fdom1_268344\u002fPSA_Test\u002fLists\u002fPSA_Webdatadase',false,'ListNode',%20'')
4. Use the second id to address the table (the first id is useless, as it is just the id of the site)
"""
SP_TABLE_ID = "F2C42F06-54FE-4242-8FAB-54FB0D191F9C"

service = Connector(SP_URL, SP_USER, SP_PWD, SP_TABLE_ID)
for row in service.getItems():
    name = row["A_Name"]
    serial_number = row["A_SNr"]
    date = datetime.datetime.strptime(row["Field1"], "%Y-%m-%d %H:%M:%S") #i.e. 2014-05-01 00:00:00
    print name, serial_number, date

Another way to get the list id, and to access the data of a table, without relying on haufe-sharepoint:

from suds import WebFault
from suds.client import *
from suds.transport.https import WindowsHttpAuthenticated
# URL of the database in sharepoint
SP_URL = 'https://mysite.sharepointsite.com/personal/dom_2348890/A_Test/_vti_bin/Lists.asmx?WSDL'
SP_USER = r'DOM\2348890'
SP_PWD = 'secret'
ntlm=WindowsHttpAuthenticated(username=SP_USER, password=SP_PWD)
client=Client(SP_URL,transport=ntlm, timeout=1000, cache=None)
client.service.GetListCollection() # Get an overview of all tables (lists) on the site, including the specific list ids 
client.service.GetListItems("{F2C4FF06-54FE-4941-8FAB-54FB0D191F9C}") # to get the items of the table with the specified id (with suds you need to include the curly braces)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.