https://github.com/gvx/wurm
A simple sqlite3-based ORM for Python
https://github.com/gvx/wurm
orm python3 sql sqlite3
Last synced: 3 months ago
JSON representation
A simple sqlite3-based ORM for Python
- Host: GitHub
- URL: https://github.com/gvx/wurm
- Owner: gvx
- License: mit
- Created: 2021-01-09T12:41:15.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-26T15:34:14.000Z (almost 5 years ago)
- Last Synced: 2025-09-15T11:49:12.950Z (7 months ago)
- Topics: orm, python3, sql, sqlite3
- Language: Python
- Homepage: https://wurm.readthedocs.io/
- Size: 87.9 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- License: LICENSE-MIT
Awesome Lists containing this project
README
wurm
====
Wurm is a simple sqlite3-based ORM.
.. contents:: **Table of Contents**
:backlinks: none
Usage
-----
.. code-block:: python
# create a table:
@dataclass
class Point(wurm.Table):
x: int
y: int
# types currently supported: int, str, bytes, bool, float, datetime.time,
# datetime.date, datetime.datetime, pathlib.Path
# sqlite3 connections cannot be shared, so call setup_connection once per thread
wurm.setup_connection(sqlite3.connect(":memory:"))
# adding new instances to the database:
point = Point(1, 0)
print(point.rowid) # None
point.insert()
print(point.rowid) # 1
# making changes:
point.x = 2
point.commit()
# simple queries:
point = Point.query(rowid=1).one() # get by rowid
Point.query(rowid=1).delete() # delete by rowid
point.delete() # delete from an object
all_points = list(Point) # iterate over a table to get instances for all rows
number_of_points = len(Point) # get the total number of rows in the table
Installation
------------
wurm is distributed on `PyPI `_ as a universal
wheel and is available on Linux/macOS and Windows and supports
Python 3.7+.
.. code-block:: bash
$ pip install wurm
Changelog
---------
0.1.0
=====
* Add ``wurm.Table.query()`` and ``wurm.Query``.
* Remove ``wurm.Table[rowid]`` getter and deleter.
* Add documentation for the public interface.
0.0.2
=====
* Ensure tables are created, even in edge cases.
* Add support for ``date``, ``time``, ``datetime`` and ``Path``.
* Add ``wurm.Unique[T]``.
License
-------
wurm is distributed under the terms of the
`MIT License `_.