GoodbyeSQL 0.5__py3-none-any.whl → 0.5.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
goodbyesql/__init__.py CHANGED
@@ -1,3 +1,10 @@
1
1
  # __init__.py
2
- from .main import GoodbyeSQL
3
- from .config import GoodbyeSQLConfig
2
+ from goodbyesql.main import GoodbyeSQL
3
+ from goodbyesql.config import GoodbyeSQLConfig
4
+ from goodbyesql.registry import set_session_provider
5
+
6
+ __all__ = [
7
+ "GoodbyeSQL",
8
+ "GoodbyeSQLConfig",
9
+ "set_session_provider"
10
+ ]
goodbyesql/config.py CHANGED
@@ -1,10 +1,15 @@
1
1
  from dataclasses import dataclass
2
2
  from typing import Any
3
+ from pydantic_settings import BaseSettings
4
+ from typing import List, Annotated
5
+ from sqlalchemy.ext.asyncio import AsyncSession
6
+ from fastapi import Depends
7
+ from goodbyesql.registry import get_session
3
8
 
4
9
 
5
10
  @dataclass
6
- class GoodbyeSQLConfig:
7
- user_model: any
11
+ class GoodbyeSQLConfig(BaseSettings):
12
+ user_model: List[str]
8
13
  username_field: str = 'username'
9
14
 
10
15
 
goodbyesql/main.py CHANGED
@@ -1,13 +1,18 @@
1
1
  from sqlalchemy.ext.asyncio import AsyncSession
2
2
  from sqlalchemy import select
3
- from config import GoodbyeSQLConfig
3
+ from goodbyesql.config import GoodbyeSQLConfig
4
+ from typing import Annotated
5
+ from fastapi import Depends
6
+ from goodbyesql.registry import get_session
7
+
8
+ DB_Session = Annotated[AsyncSession, Depends(get_session)]
4
9
 
5
10
 
6
11
  class GoodbyeSQL:
7
12
  def __init__(self, config: GoodbyeSQLConfig):
8
13
  self.config = config
9
14
 
10
- async def get_info_by_username(self, *, session: AsyncSession, username: str):
15
+ async def get_info_by_username(self, *, session: DB_Session, username: str):
11
16
 
12
17
  model = self.config.user_model
13
18
  field = getattr(model,self.config.username_field)
@@ -15,6 +20,7 @@ class GoodbyeSQL:
15
20
  query = select(model).where(field == username)
16
21
  result = await session.execute(query)
17
22
  user: None = result.scalar_one_or_none()
23
+ return user
18
24
 
19
25
 
20
26
 
goodbyesql/registry.py ADDED
@@ -0,0 +1,17 @@
1
+ from typing import Callable, Optional
2
+
3
+ _session_provider : Optional[Callable] = None
4
+
5
+ def set_session_provider(provider: Callable) -> None:
6
+ global _session_provider
7
+
8
+ _session_provider = provider
9
+
10
+ def get_session():
11
+ if _session_provider is None:
12
+ RuntimeError(
13
+ "Session have not been set up yet."
14
+ "You can set your session via set_session_provider function!"
15
+ )
16
+
17
+ return _session_provider()
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: GoodbyeSQL
3
+ Version: 0.5.3
4
+ Description-Content-Type: text/markdown
5
+ Requires-Dist: sqlalchemy==2.0.43
6
+ Requires-Dist: fastapi==0.135.1
7
+ Dynamic: description
8
+ Dynamic: description-content-type
9
+ Dynamic: requires-dist
10
+
11
+ # goodbyesql
12
+
13
+ ### Simplify SQLAlchemy. Say goodbye to repetitive database code.
14
+
15
+ `goodbyesql` is a lightweight Python library built on top of **SQLAlchemy** that helps backend developers reduce repetitive database boilerplate.
16
+
17
+ It provides a simple interface for working with common SQLAlchemy operations while keeping SQLAlchemy underneath.
18
+
19
+ ## ✨ Features
20
+
21
+ * 🐍 Built for Python backend applications
22
+ * 🗄️ Built on top of SQLAlchemy
23
+ * ⚡ Simplifies common database operations
24
+ * 🧹 Reduces repetitive SQLAlchemy boilerplate
25
+ * ⚙️ Configurable database setup
26
+ * 🔌 Custom session provider support
27
+
28
+ ## 📦 Installation
29
+
30
+ ```bash
31
+ pip install goodbyesql
32
+ ```
33
+
34
+ ## 🚀 Quick Start
35
+
36
+ ```python
37
+ from goodbyesql import GoodbyeSQL, GoodbyeSQLConfig
38
+
39
+ config = GoodbyeSQLConfig(
40
+ # your configuration
41
+ )
42
+
43
+ db = GoodbyeSQL(config)
44
+ ```
45
+
46
+ `GoodbyeSQL` provides a higher-level interface for common database operations while using SQLAlchemy internally.
47
+
48
+ ## 🔧 Session Provider
49
+
50
+ `goodbyesql` also allows you to configure your own SQLAlchemy session provider:
51
+
52
+ ```python
53
+ from goodbyesql import set_session_provider
54
+
55
+ set_session_provider(your_session_provider)
56
+ ```
57
+
58
+ This makes it possible to integrate `goodbyesql` into existing backend architectures where database sessions are already managed by the application.
59
+
60
+ ## 🏗️ How It Works
61
+
62
+ `goodbyesql` is not a replacement for SQLAlchemy.
63
+
64
+ Instead, it provides a convenient abstraction on top of it:
65
+
66
+ ```text
67
+ ┌─────────────────────┐
68
+ │ Your Application │
69
+ └──────────┬──────────┘
70
+ │
71
+ ▼
72
+ ┌─────────────────────┐
73
+ │ goodbyesql │
74
+ │ Simple DB API │
75
+ └──────────┬──────────┘
76
+ │
77
+ ▼
78
+ ┌─────────────────────┐
79
+ │ SQLAlchemy │
80
+ └──────────┬──────────┘
81
+ │
82
+ ▼
83
+ ┌─────────────────────┐
84
+ │ Database │
85
+ └─────────────────────┘
86
+ ```
87
+
88
+ The goal is simple:
89
+
90
+ > **Write less repetitive database code and focus more on your application.**
91
+
92
+ ## 🎯 Who is it for?
93
+
94
+ `goodbyesql` is designed primarily for **Python backend developers** who use SQLAlchemy and want a simpler way to handle common database functionality.
95
+
96
+ It can be especially useful in projects such as:
97
+
98
+ * REST APIs
99
+ * FastAPI applications
100
+ * Backend services
101
+ * Automation systems
102
+ * Microservices
103
+ * Other Python applications using SQLAlchemy
104
+
105
+ ## 📚 Public API
106
+
107
+ ### `GoodbyeSQL`
108
+
109
+ The main class used to work with `goodbyesql`.
110
+
111
+ ```python
112
+ from goodbyesql import GoodbyeSQL
113
+ ```
114
+
115
+ ### `GoodbyeSQLConfig`
116
+
117
+ Configuration for `GoodbyeSQL`.
118
+
119
+ ```python
120
+ from goodbyesql import GoodbyeSQLConfig
121
+ ```
122
+
123
+ ### `set_session_provider`
124
+
125
+ Configure the session provider used by `goodbyesql`.
126
+
127
+ ```python
128
+ from goodbyesql import set_session_provider
129
+ ```
130
+
131
+ ## 🚧 Project Status
132
+
133
+ `goodbyesql` is currently under active development.
134
+
135
+ The API may change in future releases as the project evolves.
136
+
137
+ Feedback, issues, and contributions are welcome.
138
+
139
+ ## 🤝 Contributing
140
+
141
+ Contributions are welcome!
142
+
143
+ Feel free to open an issue or submit a pull request if you have an idea, improvement, or bug fix.
144
+
145
+ ## 📄 License
146
+
147
+ See the `LICENSE` file for license information.
@@ -0,0 +1,9 @@
1
+ goodbyesql/__init__.py,sha256=Vb66UPBqSUh9VaiuvPIl-i_t5LU033OSMDvuDKvD6NI,245
2
+ goodbyesql/config.py,sha256=tFAx_aWD-mTCatEU50mK55XDvA0cCU-zQueeibQgHrg,392
3
+ goodbyesql/main.py,sha256=NmN98x_4kD2OTvupQhPhNvSXkPVY9O9UiVwmvqOCoiw,835
4
+ goodbyesql/registry.py,sha256=IZ1oJBu3H7nkKfhAr7showUXQjyzeTAgFAvqk-qPqPo,460
5
+ goodbyesql-0.5.3.dist-info/METADATA,sha256=6hn6Z9zDU2bKk_zPXUIpg1IdPfUcu92nZRauASnj3Oo,3895
6
+ goodbyesql-0.5.3.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
7
+ goodbyesql-0.5.3.dist-info/entry_points.txt,sha256=HJZv1j9H1L-XcIje9b7p4wQLzWB-u4VSGj9zm2b0zqQ,52
8
+ goodbyesql-0.5.3.dist-info/top_level.txt,sha256=RKJnBiGErKfK2KnnHs8AXbl8Vk7JSMu_Oozegzplb6E,11
9
+ goodbyesql-0.5.3.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: GoodbyeSQL
3
- Version: 0.5
4
- Requires-Dist: sqlalchemy==2.0.43
5
- Dynamic: requires-dist
@@ -1,8 +0,0 @@
1
- goodbyesql/__init__.py,sha256=4hJuTgjbpk-m6nLWDHGdDgF0Lf83Ih_56OpFsaISkPM,81
2
- goodbyesql/config.py,sha256=j9pIFKPHZzkgokCNsjWbXntIdA7kSgKqYHqP-og_FYE,169
3
- goodbyesql/main.py,sha256=Abxg-ozex_t7reQJ31z-reGw3xLeNICi_VPNyr7D7iA,639
4
- goodbyesql-0.5.dist-info/METADATA,sha256=fnmoMrp9vfYI0gxtpqDk32ZmmbByRD0EqiE-XSuC1Fc,114
5
- goodbyesql-0.5.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
6
- goodbyesql-0.5.dist-info/entry_points.txt,sha256=HJZv1j9H1L-XcIje9b7p4wQLzWB-u4VSGj9zm2b0zqQ,52
7
- goodbyesql-0.5.dist-info/top_level.txt,sha256=RKJnBiGErKfK2KnnHs8AXbl8Vk7JSMu_Oozegzplb6E,11
8
- goodbyesql-0.5.dist-info/RECORD,,