Skip to main content

A lightweight ORM for SQLite with advanced and simplified select capabilities.

Project description

Py_Simple_Select
Py_Simple_Select


Py_Simple_Select is a lightweight Python library designed to simplify interactions with SQLite databases. It provides a minimalistic ORM (Object-Relational Mapping) system that enables advanced querying and flexible data selection. This library is tailored to offer an easy-to-use interface while abstracting away database internals, such as primary keys and foreign keys, when they are not needed by the user.

Table of Contents


Features

  • Lightweight ORM: Interact with SQLite databases using Python objects, making database operations more intuitive and Pythonic.
  • Advanced Querying: Perform advanced selections that allow grouping results based on foreign keys, offering a powerful way to organize related data.
  • Object Simplification: Automatically filters out primary and foreign keys, returning only the relevant attributes in your objects.
  • Foreign Key Support: Full support for foreign keys, including automatic detection and grouping of results based on these relationships.
  • Ease of Use: Designed for simplicity, allowing users to focus on the data they care about without worrying about the underlying database structure.

Installation

You can install Py_Simple_Select directly from PyPI using pip:

pip install Py_Simple_Select

Usage

Create and Connect to a Database

First, let's create a database manager instance and set up our tables, including those with foreign keys:

from py_simple_select import Database_Manager

# Create a database manager instance
db : Database_Manager = Database_Manager("my_database")

# Create a table without foreign keys
db.create_table ("user", name = str, email = str)

# Create a table with a foreign key referencing the "users" table
db.create_table ("order", amount = float, user_id = int)

Insert Data into Tables

Next, we can insert data into our tables. The ORM makes it simple to add entries:

# Get the "users" table class
User : type = db.get_table_class ("user")
Order : type = db.get_table_class ("order")

# Insert records into the "users" table and records into the "orders" table with a reference to "users"
db.insert (
	User (name = "Alice", email = "alice@example.com"),
	User (name = "Bob", email = "bob@example.com"),
	Order (amount = 250.75, user_id = 1),
	Order (amount = 125.50, user_id = 2)
)

Perform Advanced Queries

You can perform advanced queries that group results based on foreign keys:

# Get the "orders" table class
grouped_orders = db.advanced_select ("orders")
for group in grouped_orders:
    print (group)

This will return a nested tuple structure where the orders are grouped by the values of their foreign keys (e.g., user_id).


License

This project is licensed under the MIT License. See the LICENSE file for more details.


Documentation

For more detailed documentation, including API references and advanced usage, please visit the official documentation.


Thanks you for using Py_Simple_Select! I hope you find it useful.

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

py_simple_select-1.0.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

Py_Simple_Select-1.0.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file py_simple_select-1.0.0.tar.gz.

File metadata

  • Download URL: py_simple_select-1.0.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for py_simple_select-1.0.0.tar.gz
Algorithm Hash digest
SHA256 618c884b48aacc7b48b9a0463b4206d394f3d789168834a9b4a5fc7a63eb99c3
MD5 506b5fdeae7af276347902024e61c412
BLAKE2b-256 ab6e77bda5553e4f0e34e8f16f27ebb357d025ef6ae766aa6c603b0f313e3612

See more details on using hashes here.

File details

Details for the file Py_Simple_Select-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for Py_Simple_Select-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1448d09d3c3a12257b867ce9140f85d8f721e966c759afbbfe6696efd4bd788c
MD5 858d5b9186e3d68fcbb8e8175a71819f
BLAKE2b-256 2b36d30fbde31eb6f5e525cf4b9aed722ae01eb001cc1d3c4071f13f74ccfeaa

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