Skip to main content

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.

Metadata

Release files for Py-Simple-Select 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Py-Simple-Select 1.0.0
File Size Uploaded
py_simple_select-1.0.0.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Py-Simple-Select 1.0.0
File Interpreter ABI Platform
Py_Simple_Select-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / py_simple_select-1.0.0.tar.gz

Download URL py_simple_select-1.0.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
618c884b48aacc7b48b9a0463b4206d394f3d789168834a9b4a5fc7a63eb99c3
BLAKE2b-256 checksum
How to use checksums
ab6e77bda5553e4f0e34e8f16f27ebb357d025ef6ae766aa6c603b0f313e3612
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / Py_Simple_Select-1.0.0-py3-none-any.whl

Download URL Py_Simple_Select-1.0.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1448d09d3c3a12257b867ce9140f85d8f721e966c759afbbfe6696efd4bd788c
BLAKE2b-256 checksum
How to use checksums
2b36d30fbde31eb6f5e525cf4b9aed722ae01eb001cc1d3c4071f13f74ccfeaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page