DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Data Engineering
  3. Databases
  4. Introducing Bulbs for Python

Introducing Bulbs for Python

Chris Smith user avatar by
Chris Smith
·
Jan. 18, 12 · Interview
Like (0)
Save
Tweet
Share
13.37K Views

Join the DZone community and get the full member experience.

Join For Free

In the process of developing Whybase, a startup debuting this fall,  developer James Thornton needed a persistence layer to model Whybase's complex relationships, and from that need came Bulbs, the open-sourced version of said framework.

Bulbs is an open-source Python persistence framework for graph databases and the first piece of a larger Web-development toolkit that will be released in the upcoming weeks.  It’s like an ORM for graphs, but instead of SQL, you use the graph-traveral language Gremlin to query the database.

-- James Thornton

Essentially, this allows you to take your code anywhere, since you no longer have to worry about vendor lock in.

Thornton provides a couple code examples on how to model and create domain objects:

Model Domain Objects

from bulbs.model import Node
from bulbs.datatype import Property, String
        
class Idea(Node):

    element_type = "idea"

    text = Property(String, nullable=False)
    stub = Property(String,"make_stub")

    def make_stub(self):
        return utils.create_stub(self.text)
           
    def after_created(self):
        Relationship.create(self,"created_by",current_user)


Create Domain Objects

>>> from whybase.idea import Idea
>>> idea = Idea(text="the key to life is perspective")
>>> idea.eid
>>> 8
>>> idea.text
'the key to life is perspetive'
>>> idea.stub
'the-key-to-life-is-perspective'


There's even this cool video by Gremlin creator, Marko Rodriguez:




So why take the time to create these graphs?  As Thornton puts it:

Graphs are a much more elegant way of storing relational data. Graphs are a fundamental data structure in computer science, and with graph databases you don’t have to mess with tables or joins – everything is explicitly joined.

--James Thornton


Bulbs is currently available for download here, and as previously mentioned, this is just the beginning of a much larger Web-Development toolkit that will be here soon.
Python (language) Relational database

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Tackling the Top 5 Kubernetes Debugging Challenges
  • Getting a Private SSL Certificate Free of Cost
  • Building a Real-Time App With Spring Boot, Cassandra, Pulsar, React, and Hilla
  • Microservices 101: Transactional Outbox and Inbox

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: