as frank pointed out in the comment I was putting path to realtime database at a wrong place, to be specific at a reference path. Correct way to connect python and realtime database was by using credentials.Certificate and write url for databaseURL when initializing app.
cred = credentials.Certificate("servicekey.json")
app = initialize_app(cred, {'databaseURL': 'http://host.0.0.1:9000/?ns=projectName'})
test = db.reference('test').get()