How to connect to a Lotus-Notes database with Python?

Question:

I have to extract data from a Notes database automatically for a data pipeline validation.
With HCL Notes I was able to connect to the database, so I know the access works.
I have the following information to access the database:
host (I got both hostname and ip address), domino server name, database name (.nsf filename)
I tried the noteslib library in the below way:

import noteslib
db = noteslib.Database('domino server name','db filename.nsf')

I also tried adding the host to the server parameter instead, but it does not work.
I receive this error:

Error connecting to ...Double-check the server and database file names, and make sure you have
read access to the database.

My question is how can I add the host and the domino server name as well (if it is required)?
Notes HCL authenticates me before accessing the database using the domino server name and the .nsf file. I tried adding the password parameter to the end, but also without luck. I am on company VPN, so that also should not be an issue.

Asked By: Looz

||

Answers:

In Order for noteslib to work you need an installed and configured HCL Notes Client on that machine. Only with an installed Notes Client the needed COM registrations and the dlls to connect to Domino are present.

In addition the Notes Client and the python version you are using need to be the same bitness: If Notes Client is 32Bit then python needs to be 32Bit. If Notes Client is 64Bit (only available since 12.0.2) then python needs to be 64Bit as well.

As soon as this requirement is met, you can simply use your example by adding the password parameter as a third parameter to your command:

db = noteslib.Database('domino server name','db filename.nsf', 'yourIDPassword')

If you still get an error when connecting to the server then you might need to put the server common name and its IP address into your hosts file.

So if your Domino- Servername is

YourServer/YourOrganization

and the IP address of that server is

192.168.1.20

then you put this into your hosts:

yourserver 192.168.1.20

Answered By: Tode

You can connect using com on windows.
I use this python library https://pypi.org/project/pywin32/

import win32com.client
import sys

notesServer = "Servername/Domain"
notesFile = "file.nsf"
notesPass = ""

#Connect to notes database on server
notesSession = win32com.client.Dispatch('Lotus.NotesSession')
notesSession.Initialize(notesPass)
notesDatabase = notesSession.GetDatabase(notesServer,notesFile)
Answered By: Marcis
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.