A Python API for Neo4j scaffolding tool
Project description
create-neo4j-python-app
This Python script streamlines setting up a new API project using a Neo4j Aura Free instance or importing existing data models from a Neo4j Workspace JSON file. The script provides two main functionalities: creating a new Neo4j Aura instance with necessary scaffolding and generating Python API code from imported models.
Features
- Neo4j Aura Instance Creation: Automatically set up a new Neo4j Aura Free instance with the provided credentials.
- Project Scaffolding: Generate a basic project directory structure for your app.
- Model Import and Generation: Import data models from a Neo4j Importer diagram to generate Python models (using neomodel) and CRUD endpoints (using FastAPI).
Usage
Installation
First, install the script using PyPI :
pip install create-neo4j-python-app
Command Line Arguments:
-i, --api-client-id: Aura API client ID for authentication.-s, --api-client-secret: Aura API client secret for authentication.-n, --instance-name: Optional name for the Neo4j Aura instance (uses the default Aura name if not specified, e.g.Instance01).-m, --import-model: Path to the model.json file exported from Neo4j Workspace.
Commands
-
Create and Scaffold a New Neo4j Aura Instance:
create-neo4j-python-app -i YOUR_API_CLIENT_ID -s YOUR_API_CLIENT_SECRET -n my-instance
This command will create a new Neo4j Aura instance named
my-instanceusing the provided client ID and secret. It also sets up the necessary project directories.Note you need to create a Neo4j Aura account, and then create an API Key to your account. This is what you can use for the above arguments.
-
Generate Models from an existing Neo4j Import diagram:
create-neo4j-python-app -m path/to/model.json
Use this command to generate Python models and CRUD operations from an existing JSON file exported from the Neo4j Workspace Import tool.
Important Notes
- Before running
--import-model, go to your Neo4j Aura instance console and use the Import tool to define your schema:- Go to the Aura Workspace
- Once your model is drawn in
Graph Models, download the model as JSON.
Run your new application
Once you have completed all the scaffolding steps, you can install requirements and run your API like this :
# Ideally, create a virtual environment with :
python3 -m venv venv
source venv/bin/activate
# Install requirements :
pip install -r requirements.txt
uvicorn --host=0.0.0.0 --port=8000 app.main:app --reload
Finally, navigate to http://localhost:8000/docs and you should see the Swagger documentation for your brand new API !
Cleanup
You can delete the Aura instance by running the script like this :
create-neo4j-python-app -i YOUR_API_CLIENT_ID -s YOUR_API_CLIENT_SECRET -n my-instance -D
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Feel free to submit issues or pull requests for improvements and bug fixes. We welcome contributions from the community!
Extending
To develop and test locally, just run :
pip install -e '.[dev]'
pytest
This repo has pre-commits for sorting imports and prettifying code :
pre-commit install
Enjoy building with Neo4j Aura! 🚀
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file create_neo4j_python_app-0.1.0.tar.gz.
File metadata
- Download URL: create_neo4j_python_app-0.1.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
add3676ba707069958f8991740a300dd86f7dc36cc538aa050f3e17d3c120ece
|
|
| MD5 |
26898395b7dd13110f697ee931a15cc6
|
|
| BLAKE2b-256 |
8937ff2e87c7b8b4e5949bb509f403575ee54ff9a13157c9c145d0d16eebb0a0
|
File details
Details for the file create_neo4j_python_app-0.1.0-py3-none-any.whl.
File metadata
- Download URL: create_neo4j_python_app-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa702f7839783d93dfd34ef2a93e50042290a68e3b1e0198bd91c5b6fde2a5e9
|
|
| MD5 |
82f371b638db3cf17e6ff687f63884ee
|
|
| BLAKE2b-256 |
5d0915a656640604ac1fb284010bf64c244b43054b500ce4538c420431c5c339
|