Adding Package `peewee` (#3897)

This commit is contained in:
Michael Weinold 2023-06-11 17:22:14 +02:00 committed by GitHub
parent 3bf1075997
commit d7873bf6ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 1 deletions

View File

@ -51,7 +51,7 @@ myst:
{pr}`3331`.
- New packages: sourmash {pr}`3635`, screed {pr}`3635`, bitstring {pr}`3635`,
deprecation {pr}`3635`, cachetools {pr}`3635`, xyzservices {pr}`3786`,
simplejson {pr}`3801`, protobuf {pr}`3813`.
simplejson {pr}`3801`, protobuf {pr}`3813`, peewee {pr}`3897`.
- Upgraded libmpfr to 4.2.0 {pr}`3756`.
- Upgraded scipy to 1.10.1 {pr}`3794`

19
packages/peewee/meta.yaml Normal file
View File

@ -0,0 +1,19 @@
package:
name: peewee
version: 3.16.2
top-level:
- peewee
requirements:
host:
- cffi
run:
- sqlite3
- cffi
source:
url: https://files.pythonhosted.org/packages/a9/50/1dd5ea74c559df4afb8391f8d05f0fec685dbe8effba13bb9072901eb288/peewee-3.16.2.tar.gz
sha256: 10769981198c7311f84a0ca8db892fa213303a8eb1305deb795a71e7bd606a91
about:
home: https://github.com/coleifer/peewee/
PyPI: https://pypi.org/project/peewee/
summary: Peewee is a simple and small ORM. It has few (but expressive) concepts, making it easy to learn and intuitive to use.
license: MIT License

View File

@ -0,0 +1,42 @@
from pytest_pyodide import run_in_pyodide
@run_in_pyodide(packages=["peewee"])
def test_peewee(selenium):
import os
from peewee import CharField, IntegerField, Model, SqliteDatabase
db = SqliteDatabase(os.path.join("/tmp", "database.db"))
# needs to be in '/tmp' for now, cf: https://github.com/jupyterlite/pyodide-kernel/issues/35
# Define a model class
class Person(Model):
name = CharField()
age = IntegerField()
class Meta:
database = db
# Connect to the database, create tables, and bind the model
with db:
db.create_tables([Person])
# Create a new person
person = Person.create(name="John Doe", age=25)
# Retrieve all people from the database
people = Person.select()
# Verify that the person was created and retrieved
assert person in people
# Update a person's age
person.age = 30
person.save()
# Delete a person
person.delete_instance()
# Verify that the person was deleted
assert person not in Person.select()