Skip to main content

The elegant and powerful SQLite3 ORM for Python

Project description

@mainpage

SQLSymphony

A simple and powerful ORM library in Python


SQLSymphony: The elegant and powerful SQLite3 ORM for Python

SQLSymphony is a lightweight ✨, powerful 💪, and high-performance⚡️, Object-Relational Mapping (ORM) library for Python, designed to simplify the interaction with SQLite3 databases. It provides a Pythonic, object-oriented interface that allows developers to focus on their application's bussiness logic rather than the underlying database management.

SQLSymphony ORM - powerful and simple ORM for python

🌟 Comparison with Alternatives

Feature SqlSymphony SQLAlchemy Peewee
💫 Simplicity ✔️ ✔️
🚀 Performance ✔️ ✔️
🌐 Database Agnosticism ✔️
📚 Comprehensive Documentation ✔️ ✔️ ✔️
🔥 Active Development ✔️ ✔️
⚡️ ASYNC Support COMING SOON

🤔 Why Choose SqlSymphony?

✨ Simplicity: SqlSymphony offers a straightforward and intuitive API for performing CRUD operations, filtering, sorting, and more, making it a breeze to work with databases in your Python projects.

💪 Flexibility: The library is designed to be database-agnostic, allowing you to switch between different SQLite3 implementations without modifying your codebase.

⚡️ Performance: SqlSymphony is optimized for performance, leveraging techniques like lazy loading and eager loading to minimize database queries and improve overall efficiency.

📚 Comprehensive Documentation: SqlSymphony comes with detailed documentation, including usage examples and API reference, to help you get started quickly and efficiently.

🔍 Maintainability: The codebase follows best practices in software engineering, including principles like SOLID, Clean Code, and modular design, ensuring the library is easy to extend and maintain.

🧪 Extensive Test Coverage: SqlSymphony is backed by a comprehensive test suite, ensuring the library's reliability and stability.

📚 Key Features

  • Intuitive API: Pythonic, object-oriented interface for interacting with SQLite3 databases.
  • Database Agnosticism: Seamlessly switch between different SQLite3 implementations.
  • Performance Optimization: Lazy loading, eager loading, and other techniques for efficient database queries.
  • Comprehensive Documentation: Detailed usage examples and API reference to help you get started.
  • Modular Design: Clean, maintainable codebase that follows best software engineering practices.
  • Extensive Test Coverage: Robust test suite to ensure the library's reliability and stability.

🚀 Getting Started

To install SqlSymphony, use pip:

pip install sqlsymphony_orm

Once installed, you can start using the library in your Python projects. Check out the documentation for detailed usage examples and API reference.

💻 Usage Examples

Creating a Model

from sqlsymphony_orm.datatypes.fields import IntegerField, CharField
from sqlsymphony_orm.models.orm_models import Model
from sqlsymphony_orm.queries import raw_sql_query
from sqlsymphony_orm.database.connection import SQLiteDBConnector


class User(Model):
    __tablename__ = "Users"
    __database__ = "users.db"

    id = IntegerField(primary_key=True)
    name = CharField(max_length=32, unique=True, null=False)

    def __repr__(self):
        return f"<User {self.id} {self.name}>"

connector = SQLiteDBConnector().connect()


@raw_sql_query(connector=connector)
def create_table(name: str):
    return 'CREATE TABLE IF NOT EXISTS %s (id INTEGER, name TEXT NOT NULL)' % (name,)


create_table('Memo')


user = User(name="Charlie")
user.save()

user2 = User(name="Carl")
user2.save()

user2.update(name="Bobby")

user3 = User(name="John")
user3.save()

user3.delete()

print(user.objects.fetch())
print(user.objects.filter(name="Bobby"))

user.view_table_info()
Cache Performance
from sqlsymphony_orm.performance.cache import cached, SingletonCache, InMemoryCache


@cached(SingletonCache(InMemoryCache, max_size=1000, ttl=60))
def fetch_data(param1: str, param2: str):
	return {'data': f'{param1} and {param2}'}

result1 = fetch_data('foo', 'bar')
print(result1) # caching
result2 = fetch_data('foo', 'bar')
print(result2) # cached

result3 = fetch_data('baz', 'qux')
print(result3) # not cached
RAW SQL Query
from sqlsymphony_orm.database.connection import SQLiteDBConnector
from sqlsymphony_orm.queries import raw_sql_query

connector = SQLiteDBConnector().connect('database.db')


@raw_sql_query(connector=connector, values=('John',))
def insert():
	return 'INSERT INTO Users (name) VALUES (?)'

Performing CRUD Operations

Create a new record
user = User(name='Charlie')
user.save()

user2 = User(name='John')
user2.save()

print(user.objects.fetch())
Update record
user2 = User(name="Carl")
user2.save()

user2.update(name="Bobby")

print(user.objects.fetch())
Delete record
user = User(name="Charlie")
user.save()

user2 = User(name="Carl")
user2.save()

user3 = User(name="John")
user3.save()

user3.delete() # delete user3
# OR
user3.delete(field_name="name", field_value="Carl") # delete user2

print(user.objects.fetch())
Filter
user = User(name="Charlie")
user.save()

user2 = User(name="Carl")
user2.save()

user2.update(name="Bobby")

user3 = User(name="John")
user3.save()

user3.delete()

print(user.objects.fetch())
print(user.objects.filter(name="Bobby"))

🤝 Contributing

We welcome contributions from the community! If you'd like to help improve SqlSymphony, please check out the contributing guidelines to get started.

💬 Support

If you encounter any issues or have questions about SqlSymphony, please:

☑️ Todos

  • Create Migrations system and Migrations Manager
  • Create ForeignKey field

🔮 Roadmap

Our future goals for SqlSymphony include:

  • 📚 Expanding support for more SQLite3 features
  • 🚀 Improving performance through further optimizations
  • ✅ Enhancing the testing suite and code coverage
  • 🌍 Translating the documentation to multiple languages
  • 🔧 Implementing advanced querying capabilities
  • 🚀 Add asynchronous operation mode
  • ☑️ Add more fields

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

sqlsymphony_orm-0.1.5.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

sqlsymphony_orm-0.1.5-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file sqlsymphony_orm-0.1.5.tar.gz.

File metadata

  • Download URL: sqlsymphony_orm-0.1.5.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Linux/6.11.1-1-cachyos

File hashes

Hashes for sqlsymphony_orm-0.1.5.tar.gz
Algorithm Hash digest
SHA256 4495e25f8138cf49175a7f0074d4651c55ea88285feaf023442d877f0234283f
MD5 f737f2866932910d456291a7567ac1be
BLAKE2b-256 00516edd0d31e658b42701af4c0eba63640db5807b41f4adc422727936236d65

See more details on using hashes here.

File details

Details for the file sqlsymphony_orm-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: sqlsymphony_orm-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Linux/6.11.1-1-cachyos

File hashes

Hashes for sqlsymphony_orm-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5fdeeb27e9bc398c3a7a3f0a10e93f9e63da11257c2a6b6772b90e275f6952c5
MD5 80cc3abb7d815df43c0873f3c87c61c7
BLAKE2b-256 67e86707965a0dc1b6415af458eaf81272bd8dfb46b83c6a48cc4ae800af7b61

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