rb-commons 0.1.1__tar.gz → 0.1.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rb-commons
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Commons of project and simplified orm based on sqlalchemy.
5
5
  Home-page: https://github.com/Abdulvoris101/rb-commons
6
6
  Author: Abdulvoris
@@ -0,0 +1,47 @@
1
+ from typing import Optional
2
+
3
+ from pydantic_settings import BaseSettings
4
+
5
+ class CommonConfigs(BaseSettings):
6
+ service_name: str = None
7
+ service_port: int = None
8
+ service_id: str = None
9
+ service_hostname: str = '127.0.0.1'
10
+ service_host: str = None
11
+
12
+ consul_host: str = '127.0.0.1'
13
+ consul_port: int = 8888
14
+
15
+ # db
16
+ POSTGRES_HOST: str = None
17
+ POSTGRES_USER: str = None
18
+ POSTGRES_PORT: int = None
19
+ POSTGRES_PASSWORD: str = None
20
+ POSTGRES_DB: str = None
21
+ DB_ALEMBIC_URL: str = None
22
+
23
+ @property
24
+ def database_url(self) -> Optional[str]:
25
+ """Construct the database URL if all required fields are present."""
26
+ required_fields = [
27
+ self.POSTGRES_USER,
28
+ self.POSTGRES_PASSWORD,
29
+ self.POSTGRES_HOST,
30
+ self.POSTGRES_PORT,
31
+ self.POSTGRES_DB
32
+ ]
33
+ if all(required_fields):
34
+ return (
35
+ f"postgresql+asyncpg://{self.POSTGRES_USER}:"
36
+ f"{self.POSTGRES_PASSWORD}@{self.POSTGRES_HOST}:"
37
+ f"{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
38
+ )
39
+ return None
40
+
41
+ class Config:
42
+ env_file = ".env"
43
+ env_file_encoding = "utf-8"
44
+ extra = "ignore"
45
+
46
+
47
+ configs = CommonConfigs()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rb-commons
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Commons of project and simplified orm based on sqlalchemy.
5
5
  Home-page: https://github.com/Abdulvoris101/rb-commons
6
6
  Author: Abdulvoris
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="rb-commons",
8
- version="0.1.1",
8
+ version="0.1.2",
9
9
  author="Abdulvoris",
10
10
  author_email="erkinovabdulvoris101@gmail.com",
11
11
  description="Commons of project and simplified orm based on sqlalchemy.",
@@ -1,30 +0,0 @@
1
- from pydantic_settings import BaseSettings
2
-
3
- class CommonConfigs(BaseSettings):
4
- service_name: str
5
- service_port: int
6
- service_id: str
7
- service_hostname: str = '127.0.0.1'
8
- service_host: str
9
-
10
- consul_host: str = '127.0.0.1'
11
- consul_port: int = 8888
12
-
13
- # db
14
- POSTGRES_HOST: str
15
- POSTGRES_USER: str
16
- POSTGRES_PORT: int
17
- POSTGRES_PASSWORD: str
18
- POSTGRES_DB: str
19
- DB_ALEMBIC_URL: str
20
-
21
- @property
22
- def database_url(self):
23
- return f"postgresql+asyncpg://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}@{self.POSTGRES_HOST}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
24
-
25
- class Config:
26
- env_file = ".env"
27
- env_file_encoding = "utf-8"
28
-
29
-
30
- configs = CommonConfigs()
File without changes