Skip to main content

A minimalist SQLite wrapper library for Python which supports ORM features.

Project description

Puchikarui

A minimalist SQLite helper library for Python 3 which supports ORM features.

Total alerts Language grade: Python Build Status codecov

Installation

puchikarui is available on PyPI and can be installed using pip.

pip install puchikarui
# or with python -m pip
python3 -m pip install puchikarui

Sample code

from puchikarui import Database

INIT_SCRIPT = '''
CREATE TABLE person (
       ID INTEGER PRIMARY KEY AUTOINCREMENT,
       name TEXT,
       age INTEGER
);
'''

class PeopleDB(Database):
  def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.add_script(INIT_SCRIPT)
        self.add_table('person', ['ID', 'name', 'age'], id_cols=('ID',))


db = PeopleDB('test.db')
people = db.person.select()
# create sample people records in the first run
if not people:
  print("Creating people records ...")
  for name, age in zip('ABCDE', range(20, 25)):
    db.person.insert(f'Person {name}', age)
  people = db.person.select()

print("All people")
print("----------------------")
for person in people:
  print(person.ID, person.name, person.age)

For more examples please see puchikarui.demo.py

python3 puchikarui.demo.py

Why puchikarui

puchikarui is a tiny, 100% pure-Python library that provides extra functionality to Python 3's sqlite3 module. It helps working directly with sqlite3 easier, with less magic, and more control, rather than hiding sqlite3 module away from the users.

Although puchikarui does provide some ORM-like features, it is NOT an ORM library. If you want ORM features, please consider PonyORM, SQLAlchemy, or peewee.

Meaning

The name puchikarui came from two Japanese words プチ (puchi) which means small, and 軽い (karui), which means light, soft, and gentle.

It represents the motivation for developing this library: a tiny, lightweight library that makes working with sqlite3 simpler.

$ python3 -m jamdict lookup "プチ"
========================================
Found entries
========================================
Entry: 1115200 | Kj:   | Kn: プチ
--------------------
1. small ((prefix))

$ python3 -m jamdict lookup "軽い"
========================================
Found entries
========================================
Entry: 1252560 | Kj:  軽い | Kn: かるい, かろい
--------------------
1. light (i.e. not heavy)/feeling light (i.e. offering little resistance, moving easily) ((adjective (keiyoushi)))
2. light (i.e. of foot)/effortless/nimble/agile ((adjective (keiyoushi)))
3. non-serious/minor/unimportant/trivial ((adjective (keiyoushi)))
4. slight/small/gentle/soft/easy/lighthearted (e.g. joke) ((adjective (keiyoushi)))
5. easy/simple ((adjective (keiyoushi)))
6. indiscriminate ((adjective (keiyoushi)))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

puchikarui-0.1a4.tar.gz (17.3 kB view details)

Uploaded Source

File details

Details for the file puchikarui-0.1a4.tar.gz.

File metadata

  • Download URL: puchikarui-0.1a4.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for puchikarui-0.1a4.tar.gz
Algorithm Hash digest
SHA256 60096c7b784dde0ca54a78d4f2e65840b7777c4851a2bfd8595cb1ec40c89532
MD5 653ddbaaf90d3f4e4e9b4348e46f7099
BLAKE2b-256 d606ec1e2062962cb2085523be880a878d8baa2a21dce2b4f28b839057e1dc88

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page