Welcome to CodeYourCraft's Amazon Neptune Tutorial! Today, we're diving into the world of graph databases, and specifically, learning about Amazon Neptune. Let's get started!
Amazon Neptune is a fully managed graph database service that makes it easy for you to run applications that work with highly connected data. It provides high performance, scalability, and seamless integration with other AWS services.
Let's create a simple database and populate it with some data.
import boto3
neptune = boto3.resource('neptune-db')
db = neptune.create_db(
EngineVersion='3.5.x',
DBName='MyFirstNeptuneDB'
)📝 Note: This code creates a new database named MyFirstNeptuneDB using Neptune's latest version.
from neptune_python_client import Client
client = Client(region='us-east-1')
# Connect to the database
conn = client.connect('MyFirstNeptuneDB', 'neptune', 'your-neptune-password')
# Insert data
cursor = conn.cursor()
cursor.execute('INSERT DATA { :person :name "John Doe" :age 30 }')📝 Note: This code connects to the newly created database, and inserts data for a person named John Doe with an age of 30.
Let's write a simple query to retrieve John Doe's age.
cursor.execute('MATCH (p:Person) RETURN p.age')
for result in cursor.all():
print(result['p.age'])📝 Note: This code queries the database for a Person node and retrieves the age attribute.
What does Amazon Neptune provide?
In the next lesson, we'll explore more advanced features of Amazon Neptune, such as traversing graphs, creating relationships between nodes, and optimizing performance.
Stay tuned and happy learning! 🎉