GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - geldata/gel-python: The official Python client library for Gel

BranchesTags
Open more actions menu

Latest commit

 

History

973 Commits
973 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
docs
docs
 
 
edgedb
edgedb
 
 
gel
gel
 
 
tests
tests
 
 
tools
tools
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
LICENSE
LICENSE
 
 
MANIFEST.in
MANIFEST.in
 
 
Makefile
Makefile
 
 
README.rst
README.rst
 
 
flake.lock
flake.lock
 
 
flake.nix
flake.nix
 
 
pyproject.toml
pyproject.toml
 
 
setup.py
setup.py
 
 

Repository files navigation

The Python driver for Gel

https://github.com/geldata/gel-python/workflows/Tests/badge.svg?event=push&branch=master https://img.shields.io/badge/join-github%20discussions-green

gel-python is the official Gel driver for Python. It provides both blocking IO and asyncio implementations.

The library requires Python 3.9 or later.

Documentation

The project documentation can be found here.

Installation

The library is available on PyPI. Use pip to install it:

$ pip install gel

Basic Usage

import datetime
import gel

def main():
    client = gel.create_client()
    # Create a User object type
    client.execute('''
        CREATE TYPE User {
            CREATE REQUIRED PROPERTY name -> str;
            CREATE PROPERTY dob -> cal::local_date;
        }
    ''')

    # Insert a new User object
    client.query('''
        INSERT User {
            name := <str>$name,
            dob := <cal::local_date>$dob
        }
    ''', name='Bob', dob=datetime.date(1984, 3, 1))

    # Select User objects.
    user_set = client.query(
        'SELECT User {name, dob} FILTER .name = <str>$name', name='Bob')
    # *user_set* now contains
    # Set{Object{name := 'Bob', dob := datetime.date(1984, 3, 1)}}

    # Close the client.
    client.close()

if __name__ == '__main__':
    main()

Using the models generator

We provide a models generator that lets you build queries programmatically, and generate Pydantic models directly from your schema.

To use, run the following command:

$ gel generate py/models

This will find your Python project and add a models package to it. Then you can use the generated models to build queries and mutate instances of your objects directly.

import datetime
from models import User, std
from gel import create_client

def main():
    client = create_client()

    # Create a new User instance and save it to the database
    bob = User(name='Bob', dob=datetime.date(1984, 3, 1))
    client.save(bob)

    # Select all Users
    users = client.query(User)

    # Select all users with names like "Bob"
    bob_like = client.query(User.filter(lambda u: std.ilike(u.name, '%bob%')))

    # Update an object
    bob.name = 'Robert'
    client.save(bob)

    # Delete an object
    client.execute(User.filter(id=bob.id).delete())

    client.close()

if __name__ == '__main__':
    main()

Development

Instructions for installing Gel and gel-python locally can be found at docs.geldata.com/resources/guides/contributing/code.

To run the test suite, run $ python setup.py test.

License

gel-python is developed and distributed under the Apache 2.0 license.

About

The official Python client library for Gel

geldata.com

Topics

asynchronousasynciodatabase-driveredgedbgelhigh-performancepython3synchronous

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

415 stars

Watchers

9 watching

Forks

49 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.