Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vizonex/sqltable
A Msgspec Sqlalchemy Library
https://github.com/vizonex/sqltable
msgspec orm python3 sqlalchemy
Last synced: 7 days ago
JSON representation
A Msgspec Sqlalchemy Library
- Host: GitHub
- URL: https://github.com/vizonex/sqltable
- Owner: Vizonex
- License: mit
- Created: 2025-01-26T01:51:33.000Z (11 days ago)
- Default Branch: main
- Last Pushed: 2025-01-26T01:53:58.000Z (11 days ago)
- Last Synced: 2025-01-26T02:50:09.069Z (11 days ago)
- Topics: msgspec, orm, python3, sqlalchemy
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQLTable
A Library Inspired by SQLModel that merges Msgspec and SQLAlchemy together.## Example
```python
from sqltable import SQLTable, Column, table
from typing import Optional, Annotated# SQLAlchemy can be directly used for all database operations
from sqlalchemy import select# SQLTable is a subclass of msgspec.Struct
# This would be an example of using SQLTable as a declarative base
class IDTable(SQLTable):
id:Annotated[Optional[int], Column(primary_key=True)] = None# When using a table wrapper we declare the table for use in our database
# This is different from SQLModel as there is less lag/overhang during our inital setup.
@table
class NameTable(IDTable, kw_only=True):
name:strif __name__ == "__main__":
print(select(NameTable).where(NameTable.id > 1))
```## Why SQLTable
As a fan of __SQLModel__ I was fond of the way it worked over just sqlalchemy but as
I started using it more, I noticed many flaws as well as a large amount of unrequired spaghetti-code.
As I started to dig out the problems I was experiencing such as lag in load-times, relationships not
loading into the json responses as well as the slow response times to pull requests I finally decided
enough was enough and If I would be honest I am kinda glad I found msgspec soon after to satisfy this
slowness as well as cut time-consumptions down. Originally I was going to develop my own library called
[CyClass](https://github.com/Vizonex/Cyclass) due to the difficulty of wrapping msgspec to sqlalchemy but
as time rolled on I began to find many intresting results as well as better solutions to my problems
and so now here we are, another successful library that I relate a lot to my first challenge which was winloop.
And If I am going to be fair, why write a class twice when you could only do it once with SQLTable?There still maybe cases where you might need SQLModel still so I will see about thinking of ways you could use
both of them at the same time.I hope SQLTable will be the future of databases and I can't wait to see what you, other people as
well as what companies big and small will end up doing with it.SQLTable still has a long way to go and I plan to make a way to use `AsyncAttrs` with it.
# NOTES
- This Library is going to get changed a lot until then this is still all in testing phase
- I am changing how the api works a ton thanks to inputs/comments from [the SQLAlchemy Devs](https://github.com/sqlalchemy/sqlalchemy/discussions/12278#discussioncomment-11972815)## TODOs
- [ ] Pypi Release
- [ ] Youtube Presentation (Maybe if I am up to it mentally)