Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3760020
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:24:25+00:00 2026-05-19T10:24:25+00:00

I am working with Neo4j graph database, and would like to adapt one of

  • 0

I am working with Neo4j graph database, and would like to adapt one of the current REST libraries. Imagine a case with a database with 20 nodes.

>>> db = Database("http://localhost:7474")

I would like the API to be as simple as possible, so that it would be possible to get the 14th node with something similar to this:

>>> db[14]

In Neo4j, every node has a numeric key. This means that db[14] maps very nicely to http://localhost:7474/db/data/node/14 However, I don’t want to load every node from the database into the db object. My preferred behaviour is to lookup node 14, and raise an IndexError if the value doesn’t exist in the database. That is, I want the db object to be empty but pretend to have a value.

Is it possible to craft something that looks like a list, but behaves significantly differently?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T10:24:26+00:00Added an answer on May 19, 2026 at 10:24 am

    Yes, you can write a custom class that implements __getitem__ and generates a result dynamically.

    >>> class MyDatabase(object):
    ...     def __getitem__(self, x):
    ...         if 10 <= x <= 15:
    ...             return "foo"
    ...         else:
    ...             raise IndexError('key not in database')
    ...
    >>> db = MyDatabase()
    >>> db[12]
    foo
    

    See Special method names for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with SpringData's Neo4j graph DB hello-worlds example and I ran across
I am trying to send a http request to a neo4j database using node.js.
I'm trying to create sample server plugin for Neo4j REST server based on http://docs.neo4j.org/chunked/snapshot/server-plugins.html
Im working on a play! app using the Neo4j libraries. Neo4j is working fine,
I'm working with a quite big Neo4J setup with more than 60,000 nodes. Each
I have a graph in Neo4j in which nodes represent random points in the
Is there a .NET version/binding for Neo4j? It looks like exactly what I want,
Working on a website http://www.ArenaText.com written in asp.net with Microsoft AJAX control toolkit. iPad
Working sample using one Table SELECT t.* FROM ( SELECT TITLE.name, (TITLE.value-TITLE.msp) AS Lower,
Working example: http://alpha.jsfiddle.net/gTpWv/ Both of the methods work separately, but once regexp for smilies

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.