An open API service indexing awesome lists of open source software.

https://github.com/mfussenegger/crate-peewee

Crate driver for peewee
https://github.com/mfussenegger/crate-peewee

Last synced: 6 months ago
JSON representation

Crate driver for peewee

Awesome Lists containing this project

README

          

============
crate-peewee
============

.. image:: https://img.shields.io/pypi/wheel/crate-peewee.svg
:target: https://pypi.python.org/pypi/crate-peewee/
:alt: Wheel

.. image:: https://img.shields.io/pypi/v/crate-peewee.svg
:target: https://pypi.python.org/pypi/crate-peewee/
:alt: PyPI Version

.. image:: https://img.shields.io/pypi/pyversions/crate-peewee.svg
:target: https://pypi.python.org/pypi/crate-peewee/
:alt: Python Version

Crate driver for `peewee `_, a small, expressive ORM.

Most basic operations work. Support for special Crate features like fulltext
search or object and array fields is still a work in progress.

For a full documentation take a look at the `peewee documentation
`_.

Usage
=====

Use peewee with Crate::

from peewee import Model, CharField
from crate.peewee import CrateDatabase
from uuid import uuid4

db = CrateDatabase()
db.connect()

def gen_key():
return str(uuid4())

class User(Model):
id = CharField(null=True, default=gen_key, primary_key=True)
name = CharField(null=True)
class Meta:
database = db

db.create_tables([User], safe=True)
arthur = User.create(name='Arthur')
db.execute_sql('refresh table user')

print([u for u in User.select(User.name).tuples()])