Skip to content

Conversation

Bit-urd
Copy link

@Bit-urd Bit-urd commented Sep 7, 2025

Summary

Fixes Neo4j driver to properly handle custom database configurations. The driver now correctly passes the database parameter
instead of hardcoding the default 'neo4j' database name.

Type of Change

  • Bug fix
  • New feature
  • Performance improvement
  • Documentation/Tests

Objective

For new features and performance improvements: N/A - This is a bug fix.

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • All existing tests pass

Breaking Changes

  • This PR contains breaking changes

Checklist

  • Code follows project style guidelines (make lint passes)
  • Self-review completed
  • Documentation updated where necessary
  • No secrets or sensitive information committed

Related Issues

#851

@danielchalef
Copy link
Member

danielchalef commented Sep 7, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Bit-urd
Copy link
Author

Bit-urd commented Sep 7, 2025

I have read the CLA Document and I hereby sign the CLA

danielchalef added a commit that referenced this pull request Sep 7, 2025
@Bit-urd
Copy link
Author

Bit-urd commented Sep 7, 2025

this is my test case

import asyncio
from datetime import datetime
from os import getenv

from graphiti_core.driver.neo4j_driver import Neo4jDriver
from graphiti_core.graphiti import Graphiti
from graphiti_core.utils.maintenance import clear_data


async def main():
    password = getenv("NEO4J_PASSWORD")
    # Default database test
    print("=== Default database (neo4j) ===")
    driver1 = Neo4jDriver("bolt://10.0.0.2:7687", "neo4j", password, "neo4j")
    client1 = Graphiti(graph_driver=driver1)
    await client1.build_indices_and_constraints()
    await clear_data(client1.driver)

    await client1.add_episode(
        "episode1",
        "User Tom purchased an iPhone",
        "Test episode data",
        datetime.now()
    )
    results1 = await client1.search("Tom")
    print(f"Default database search results: {results1} items")
    await driver1.close()
    
    # Custom database test
    print("\n=== Custom database (testdb) ===")
    try:
        driver2 = Neo4jDriver("bolt://10.0.0.2:7687", "neo4j", password, "biturd")
        client2 = Graphiti(graph_driver=driver2)
        await client2.build_indices_and_constraints()
        await clear_data(client2.driver)

        await client2.add_episode(
            "episode2",
            "User John purchased a Iphone",
            "Test episode data",
            datetime.now()
        )
        results2 = await client2.search("John")
        print(f"Custom database search results: {results2} items")
        await driver2.close()
    except Exception as e:
        if "DatabaseNotFound" in str(e):
            print("Successfully connected to testdb database (database doesn't exist, as expected)")
        else:
            print(f"Error: {e}")
    
    print("\nDatabase parameter fix test completed")

if __name__ == "__main__":
    asyncio.run(main())

before fix :
image

after fix:
image

@bfhealy
Copy link

bfhealy commented Sep 10, 2025

This would also address #798

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants