devsetgo-lib 0.12.0__tar.gz → 0.12.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.
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/PKG-INFO +1 -2
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/README.md +0 -1
- devsetgo_lib-0.12.2/dsg_lib/__init__.py +3 -0
- devsetgo_lib-0.12.2/dsg_lib/async_database_functions/__import_sqlalchemy.py +118 -0
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/async_database_functions/async_database.py +32 -5
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/async_database_functions/base_schema.py +49 -84
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/async_database_functions/database_config.py +54 -100
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/async_database_functions/database_operations.py +511 -345
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/common_functions/calendar_functions.py +43 -36
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/common_functions/file_functions.py +178 -141
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/common_functions/folder_functions.py +45 -22
- devsetgo_lib-0.12.2/dsg_lib/common_functions/logging_config.py +201 -0
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/common_functions/patterns.py +23 -23
- devsetgo_lib-0.12.2/dsg_lib/fastapi_functions/_all_codes.py +352 -0
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/fastapi_functions/http_codes.py +66 -44
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/fastapi_functions/system_health_endpoints.py +114 -85
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/pyproject.toml +32 -2
- devsetgo_lib-0.12.0/dsg_lib/__init__.py +0 -18
- devsetgo_lib-0.12.0/dsg_lib/common_functions/logging_config.py +0 -176
- devsetgo_lib-0.12.0/dsg_lib/fastapi_functions/_all_codes.py +0 -282
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/.gitignore +0 -0
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/LICENSE +0 -0
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/async_database_functions/__init__.py +0 -0
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/common_functions/__init__.py +0 -0
- {devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/fastapi_functions/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: devsetgo_lib
|
|
3
|
-
Version: 0.12.
|
|
3
|
+
Version: 0.12.2
|
|
4
4
|
Summary: DevSetGo Common Library provides reusable Python functions for enhanced code efficiency. It includes utilities for file operations, calendar, pattern matching, logging, FastAPI endpoints, and async database handling with CRUD operations.
|
|
5
5
|
Project-URL: Homepage, https://github.com/devsetgo/devsetgo_lib
|
|
6
6
|
Project-URL: Documentation, https://devsetgo.github.io/devsetgo_lib/
|
|
@@ -168,4 +168,3 @@ Contributions and feedback are highly appreciated. Please refer to our [Contribu
|
|
|
168
168
|
|
|
169
169
|
## Further Documentation
|
|
170
170
|
For more detailed information, visit [LINK_TO_DETAILED_DOCUMENTATION](https://devsetgo.github.io/devsetgo_lib/).
|
|
171
|
-
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from typing import Tuple
|
|
3
|
+
|
|
4
|
+
from loguru import logger
|
|
5
|
+
from packaging import version as packaging_version
|
|
6
|
+
|
|
7
|
+
# Importing AsyncDatabase class from local module async_database
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def import_sqlalchemy() -> Tuple:
|
|
11
|
+
"""
|
|
12
|
+
Imports and returns SQLAlchemy components.
|
|
13
|
+
|
|
14
|
+
This function attempts to import SQLAlchemy and its components. It checks the version of SQLAlchemy
|
|
15
|
+
and raises an ImportError if the version is less than the minimum required version.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
tuple: A tuple containing the following SQLAlchemy components:
|
|
19
|
+
- sqlalchemy: The SQLAlchemy module.
|
|
20
|
+
- MetaData: The MetaData class from SQLAlchemy.
|
|
21
|
+
- create_engine: The create_engine function from SQLAlchemy.
|
|
22
|
+
- text: The text function from SQLAlchemy.
|
|
23
|
+
- Column: The Column class from SQLAlchemy.
|
|
24
|
+
- DateTime: The DateTime class from SQLAlchemy.
|
|
25
|
+
- String: The String class from SQLAlchemy.
|
|
26
|
+
- IntegrityError: The IntegrityError exception from SQLAlchemy.
|
|
27
|
+
- SQLAlchemyError: The SQLAlchemyError exception from SQLAlchemy.
|
|
28
|
+
- AsyncSession: The AsyncSession class from SQLAlchemy.
|
|
29
|
+
- create_async_engine: The create_async_engine function from SQLAlchemy.
|
|
30
|
+
- select: The select function from SQLAlchemy.
|
|
31
|
+
- declarative_base: The declarative_base function from SQLAlchemy.
|
|
32
|
+
- sessionmaker: The sessionmaker function from SQLAlchemy.
|
|
33
|
+
- func: The func object from SQLAlchemy.
|
|
34
|
+
- NoResultFound: The NoResultFound exception from SQLAlchemy.
|
|
35
|
+
|
|
36
|
+
Raises:
|
|
37
|
+
ImportError: If the SQLAlchemy version is less than the minimum required version.
|
|
38
|
+
|
|
39
|
+
"""
|
|
40
|
+
min_version = '2.0.0' # Minimum required version of SQLAlchemy
|
|
41
|
+
|
|
42
|
+
logger.info('Attempting to import SQLAlchemy...')
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
# Import SQLAlchemy and its components
|
|
46
|
+
import sqlalchemy
|
|
47
|
+
from sqlalchemy import Column, DateTime, MetaData, String, create_engine, text
|
|
48
|
+
from sqlalchemy.exc import IntegrityError, SQLAlchemyError
|
|
49
|
+
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
|
|
50
|
+
from sqlalchemy.future import select
|
|
51
|
+
from sqlalchemy.orm import declarative_base, sessionmaker
|
|
52
|
+
from sqlalchemy.orm.exc import NoResultFound
|
|
53
|
+
from sqlalchemy.sql import func
|
|
54
|
+
|
|
55
|
+
logger.info('Successfully imported SQLAlchemy.')
|
|
56
|
+
|
|
57
|
+
except ImportError: # pragma: no cover
|
|
58
|
+
# Handle the case where SQLAlchemy is not installed
|
|
59
|
+
logger.error('Failed to import SQLAlchemy.')
|
|
60
|
+
create_engine = text = sqlalchemy = None # pragma: no cover
|
|
61
|
+
|
|
62
|
+
# Check SQLAlchemy version
|
|
63
|
+
if sqlalchemy is not None and packaging_version.parse(
|
|
64
|
+
sqlalchemy.__version__
|
|
65
|
+
) < packaging_version.parse(min_version):
|
|
66
|
+
# If the installed version is less than the minimum required version, raise an error
|
|
67
|
+
logger.error(
|
|
68
|
+
f'SQLAlchemy version >= {min_version} required, run `pip install --upgrade sqlalchemy`'
|
|
69
|
+
)
|
|
70
|
+
raise ImportError(
|
|
71
|
+
f'SQLAlchemy version >= {min_version} required, run `pip install --upgrade sqlalchemy`'
|
|
72
|
+
) # pragma: no cover
|
|
73
|
+
|
|
74
|
+
logger.info('Returning SQLAlchemy components.')
|
|
75
|
+
|
|
76
|
+
# Return the imported SQLAlchemy components
|
|
77
|
+
return (
|
|
78
|
+
sqlalchemy,
|
|
79
|
+
MetaData,
|
|
80
|
+
create_engine,
|
|
81
|
+
text,
|
|
82
|
+
IntegrityError,
|
|
83
|
+
SQLAlchemyError,
|
|
84
|
+
AsyncSession,
|
|
85
|
+
create_async_engine,
|
|
86
|
+
select,
|
|
87
|
+
declarative_base,
|
|
88
|
+
sessionmaker,
|
|
89
|
+
Column,
|
|
90
|
+
DateTime,
|
|
91
|
+
String,
|
|
92
|
+
func,
|
|
93
|
+
NoResultFound,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# Call the import_sqlalchemy function and unpack its return value
|
|
98
|
+
# into several variables. Each variable corresponds to a component
|
|
99
|
+
# of SQLAlchemy that we want to use in our code.
|
|
100
|
+
|
|
101
|
+
(
|
|
102
|
+
sqlalchemy, # The SQLAlchemy module
|
|
103
|
+
MetaData, # The MetaData class from SQLAlchemy
|
|
104
|
+
create_engine, # The create_engine function from SQLAlchemy
|
|
105
|
+
text, # The text function from SQLAlchemy
|
|
106
|
+
IntegrityError, # The IntegrityError exception from SQLAlchemy
|
|
107
|
+
SQLAlchemyError, # The SQLAlchemyError exception from SQLAlchemy
|
|
108
|
+
AsyncSession, # The AsyncSession class from SQLAlchemy
|
|
109
|
+
create_async_engine, # The create_async_engine function from SQLAlchemy
|
|
110
|
+
select, # The select function from SQLAlchemy
|
|
111
|
+
declarative_base, # The declarative_base function from SQLAlchemy
|
|
112
|
+
sessionmaker, # The sessionmaker function from SQLAlchemy
|
|
113
|
+
Column, # The Column class from SQLAlchemy
|
|
114
|
+
DateTime, # The DateTime class from SQLAlchemy
|
|
115
|
+
String, # The String class from SQLAlchemy
|
|
116
|
+
func, # The func object from SQLAlchemy
|
|
117
|
+
NoResultFound, # The NoResultFound exception from SQLAlchemy
|
|
118
|
+
) = import_sqlalchemy() # Call the function that imports SQLAlchemy and checks its version
|
{devsetgo_lib-0.12.0 → devsetgo_lib-0.12.2}/dsg_lib/async_database_functions/async_database.py
RENAMED
|
@@ -16,6 +16,33 @@ database operations. It provides methods to get a database session and to create
|
|
|
16
16
|
tables in the database.
|
|
17
17
|
|
|
18
18
|
This module uses the logger from the dsg_lib.common_functions for logging.
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
```python
|
|
22
|
+
from dsg_lib.async_database_functions import (
|
|
23
|
+
async_database,
|
|
24
|
+
base_schema,
|
|
25
|
+
database_config,
|
|
26
|
+
database_operations,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Create a DBConfig instance
|
|
30
|
+
config = {
|
|
31
|
+
"database_uri": "sqlite+aiosqlite:///:memory:?cache=shared",
|
|
32
|
+
"echo": False,
|
|
33
|
+
"future": True,
|
|
34
|
+
"pool_recycle": 3600,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# create database configuration
|
|
38
|
+
db_config = database_config.DBConfig(config)
|
|
39
|
+
|
|
40
|
+
# Create an AsyncDatabase instance
|
|
41
|
+
async_db = async_database.AsyncDatabase(db_config)
|
|
42
|
+
|
|
43
|
+
# Create a DatabaseOperations instance
|
|
44
|
+
db_ops = database_operations.DatabaseOperations(async_db)
|
|
45
|
+
```
|
|
19
46
|
"""
|
|
20
47
|
|
|
21
48
|
|
|
@@ -54,7 +81,7 @@ class AsyncDatabase:
|
|
|
54
81
|
"""
|
|
55
82
|
self.db_config = db_config
|
|
56
83
|
self.Base = BASE
|
|
57
|
-
logger.debug(
|
|
84
|
+
logger.debug('AsyncDatabase initialized')
|
|
58
85
|
|
|
59
86
|
def get_db_session(self):
|
|
60
87
|
"""This method returns a context manager that provides a new database
|
|
@@ -65,7 +92,7 @@ class AsyncDatabase:
|
|
|
65
92
|
Returns: contextlib._GeneratorContextManager: A context manager that
|
|
66
93
|
provides a new database session.
|
|
67
94
|
"""
|
|
68
|
-
logger.debug(
|
|
95
|
+
logger.debug('Getting database session')
|
|
69
96
|
return self.db_config.get_db_session()
|
|
70
97
|
|
|
71
98
|
async def create_tables(self):
|
|
@@ -75,7 +102,7 @@ class AsyncDatabase:
|
|
|
75
102
|
|
|
76
103
|
Returns: None
|
|
77
104
|
"""
|
|
78
|
-
logger.debug(
|
|
105
|
+
logger.debug('Creating tables')
|
|
79
106
|
try:
|
|
80
107
|
# Bind the engine to the metadata of the base class
|
|
81
108
|
self.Base.metadata.bind = self.db_config.engine
|
|
@@ -84,8 +111,8 @@ class AsyncDatabase:
|
|
|
84
111
|
async with self.db_config.engine.begin() as conn:
|
|
85
112
|
# Run a function in a synchronous manner
|
|
86
113
|
await conn.run_sync(self.Base.metadata.create_all)
|
|
87
|
-
logger.info(
|
|
114
|
+
logger.info('Tables created successfully')
|
|
88
115
|
except Exception as ex: # pragma: no cover
|
|
89
116
|
# Log the error and raise it
|
|
90
|
-
logger.error(f
|
|
117
|
+
logger.error(f'Error creating tables: {ex}') # pragma: no cover
|
|
91
118
|
raise # pragma: no cover
|
|
@@ -17,7 +17,9 @@ that are needed for most models like `pkid`, `date_created`, and `date_updated`.
|
|
|
17
17
|
To create a new database model, import this module and extend the `SchemaBase`
|
|
18
18
|
class.
|
|
19
19
|
|
|
20
|
-
Example:
|
|
20
|
+
Example:
|
|
21
|
+
```python
|
|
22
|
+
from dsg_lib.async_database_functions import base_schema
|
|
21
23
|
|
|
22
24
|
class MyModel(base_schema.SchemaBaseSQLite):
|
|
23
25
|
# Define your model-specific columns here my_column =
|
|
@@ -29,72 +31,35 @@ class MyModel(base_schema.SchemaBaseSQLite):
|
|
|
29
31
|
|
|
30
32
|
# Importing required modules from Python's standard library
|
|
31
33
|
import datetime
|
|
32
|
-
from typing import Tuple
|
|
33
34
|
from uuid import uuid4
|
|
34
35
|
|
|
35
|
-
from
|
|
36
|
+
from .__import_sqlalchemy import import_sqlalchemy
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
def import_sqlalchemy() -> Tuple:
|
|
39
|
-
"""
|
|
40
|
-
This function tries to import SQLAlchemy and its components, and raises an
|
|
41
|
-
ImportError if SQLAlchemy is not installed or if the installed version is
|
|
42
|
-
not compatible with the minimum required version.
|
|
43
|
-
|
|
44
|
-
Returns:
|
|
45
|
-
Tuple: A tuple containing the imported SQLAlchemy module and its
|
|
46
|
-
components (Column, DateTime, String, text).
|
|
47
|
-
|
|
48
|
-
Raises:
|
|
49
|
-
ImportError: If SQLAlchemy is not installed or if the installed version
|
|
50
|
-
is not compatible with the minimum required version.
|
|
51
|
-
|
|
52
|
-
Example: ```python from dsg_lib import base_schema sqlalchemy, Column,
|
|
53
|
-
DateTime, String, text = base_schema.import_sqlalchemy() ```
|
|
54
|
-
"""
|
|
55
|
-
try:
|
|
56
|
-
import sqlalchemy
|
|
57
|
-
from sqlalchemy import Column, DateTime, String
|
|
58
|
-
from sqlalchemy.sql import text
|
|
59
|
-
|
|
60
|
-
except ImportError:
|
|
61
|
-
Column = DateTime = String = text = sqlalchemy = None
|
|
62
|
-
|
|
63
|
-
# Check SQLAlchemy version
|
|
64
|
-
min_version = "1.4.0" # replace with your minimum required version
|
|
65
|
-
if sqlalchemy is not None and packaging_version.parse(
|
|
66
|
-
sqlalchemy.__version__
|
|
67
|
-
) < packaging_version.parse(min_version):
|
|
68
|
-
raise ImportError(
|
|
69
|
-
f"SQLAlchemy version >= {min_version} required, run `pip install --upgrade sqlalchemy`"
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
sqlalchemy,
|
|
74
|
-
Column,
|
|
75
|
-
DateTime,
|
|
76
|
-
String,
|
|
77
|
-
text,
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
# Call the function at the module level to import SQLAlchemy and its components
|
|
82
38
|
(
|
|
83
|
-
sqlalchemy,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
39
|
+
sqlalchemy, # The SQLAlchemy module
|
|
40
|
+
MetaData, # The MetaData class from SQLAlchemy
|
|
41
|
+
create_engine, # The create_engine function from SQLAlchemy
|
|
42
|
+
text, # The text function from SQLAlchemy
|
|
43
|
+
IntegrityError, # The IntegrityError exception from SQLAlchemy
|
|
44
|
+
SQLAlchemyError, # The SQLAlchemyError exception from SQLAlchemy
|
|
45
|
+
AsyncSession, # The AsyncSession class from SQLAlchemy
|
|
46
|
+
create_async_engine, # The create_async_engine function from SQLAlchemy
|
|
47
|
+
select, # The select function from SQLAlchemy
|
|
48
|
+
declarative_base, # The declarative_base function from SQLAlchemy
|
|
49
|
+
sessionmaker, # The sessionmaker function from SQLAlchemy
|
|
50
|
+
Column, # The Column class from SQLAlchemy
|
|
51
|
+
DateTime, # The DateTime class from SQLAlchemy
|
|
52
|
+
String, # The String class from SQLAlchemy
|
|
53
|
+
func, # The func object from SQLAlchemy
|
|
54
|
+
NoResultFound, # The NoResultFound exception from SQLAlchemy
|
|
55
|
+
) = import_sqlalchemy() # Call the function that imports SQLAlchemy and checks its version
|
|
89
56
|
|
|
90
57
|
|
|
91
58
|
# comments
|
|
92
|
-
uuid_comment =
|
|
93
|
-
date_created_comment =
|
|
94
|
-
"Date and time when a row was inserted, defaults to current UTC time"
|
|
95
|
-
)
|
|
59
|
+
uuid_comment = 'Unique identifier for each record, a string representation of a UUID'
|
|
60
|
+
date_created_comment = 'Date and time when a row was inserted, defaults to current UTC time'
|
|
96
61
|
date_updated_comment = (
|
|
97
|
-
|
|
62
|
+
'Date and time when a row was last updated, defaults to current UTC time on update'
|
|
98
63
|
)
|
|
99
64
|
|
|
100
65
|
|
|
@@ -115,7 +80,7 @@ class SchemaBaseSQLite:
|
|
|
115
80
|
|
|
116
81
|
Example:
|
|
117
82
|
```python
|
|
118
|
-
from dsg_lib import base_schema
|
|
83
|
+
from dsg_lib.async_database_functions import base_schema
|
|
119
84
|
from sqlalchemy.orm import declarative_base
|
|
120
85
|
|
|
121
86
|
BASE = declarative_base()
|
|
@@ -174,7 +139,7 @@ class SchemaBasePostgres:
|
|
|
174
139
|
|
|
175
140
|
Example:
|
|
176
141
|
```python
|
|
177
|
-
from dsg_lib import base_schema
|
|
142
|
+
from dsg_lib.async_database_functions import base_schema
|
|
178
143
|
from sqlalchemy.orm import declarative_base
|
|
179
144
|
|
|
180
145
|
BASE = declarative_base()
|
|
@@ -233,7 +198,7 @@ class SchemaBaseMySQL:
|
|
|
233
198
|
|
|
234
199
|
Example:
|
|
235
200
|
```python
|
|
236
|
-
from dsg_lib import base_schema
|
|
201
|
+
from dsg_lib.async_database_functions import base_schema
|
|
237
202
|
from sqlalchemy.orm import declarative_base
|
|
238
203
|
|
|
239
204
|
BASE = declarative_base()
|
|
@@ -259,7 +224,7 @@ class SchemaBaseMySQL:
|
|
|
259
224
|
date_created = Column(
|
|
260
225
|
DateTime,
|
|
261
226
|
index=True,
|
|
262
|
-
server_default=text(
|
|
227
|
+
server_default=text('UTC_TIMESTAMP()'),
|
|
263
228
|
comment=date_created_comment,
|
|
264
229
|
)
|
|
265
230
|
|
|
@@ -268,8 +233,8 @@ class SchemaBaseMySQL:
|
|
|
268
233
|
date_updated = Column(
|
|
269
234
|
DateTime,
|
|
270
235
|
index=True,
|
|
271
|
-
server_default=text(
|
|
272
|
-
onupdate=text(
|
|
236
|
+
server_default=text('UTC_TIMESTAMP()'),
|
|
237
|
+
onupdate=text('UTC_TIMESTAMP()'),
|
|
273
238
|
comment=date_updated_comment,
|
|
274
239
|
)
|
|
275
240
|
|
|
@@ -292,7 +257,7 @@ class SchemaBaseOracle:
|
|
|
292
257
|
|
|
293
258
|
Example:
|
|
294
259
|
```python
|
|
295
|
-
from dsg_lib import base_schema
|
|
260
|
+
from dsg_lib.async_database_functions import base_schema
|
|
296
261
|
from sqlalchemy.orm import declarative_base
|
|
297
262
|
|
|
298
263
|
BASE = declarative_base()
|
|
@@ -318,7 +283,7 @@ class SchemaBaseOracle:
|
|
|
318
283
|
date_created = Column(
|
|
319
284
|
DateTime,
|
|
320
285
|
index=True,
|
|
321
|
-
server_default=text(
|
|
286
|
+
server_default=text('SYS_EXTRACT_UTC(SYSTIMESTAMP)'),
|
|
322
287
|
comment=date_created_comment,
|
|
323
288
|
)
|
|
324
289
|
|
|
@@ -327,8 +292,8 @@ class SchemaBaseOracle:
|
|
|
327
292
|
date_updated = Column(
|
|
328
293
|
DateTime,
|
|
329
294
|
index=True,
|
|
330
|
-
server_default=text(
|
|
331
|
-
onupdate=text(
|
|
295
|
+
server_default=text('SYS_EXTRACT_UTC(SYSTIMESTAMP)'),
|
|
296
|
+
onupdate=text('SYS_EXTRACT_UTC(SYSTIMESTAMP)'),
|
|
332
297
|
comment=date_updated_comment,
|
|
333
298
|
)
|
|
334
299
|
|
|
@@ -351,7 +316,7 @@ class SchemaBaseMSSQL:
|
|
|
351
316
|
|
|
352
317
|
Example:
|
|
353
318
|
```python
|
|
354
|
-
from dsg_lib import base_schema
|
|
319
|
+
from dsg_lib.async_database_functions import base_schema
|
|
355
320
|
from sqlalchemy.orm import declarative_base
|
|
356
321
|
|
|
357
322
|
BASE = declarative_base()
|
|
@@ -377,7 +342,7 @@ class SchemaBaseMSSQL:
|
|
|
377
342
|
date_created = Column(
|
|
378
343
|
DateTime,
|
|
379
344
|
index=True,
|
|
380
|
-
server_default=text(
|
|
345
|
+
server_default=text('GETUTCDATE()'),
|
|
381
346
|
comment=date_created_comment,
|
|
382
347
|
)
|
|
383
348
|
|
|
@@ -386,8 +351,8 @@ class SchemaBaseMSSQL:
|
|
|
386
351
|
date_updated = Column(
|
|
387
352
|
DateTime,
|
|
388
353
|
index=True,
|
|
389
|
-
server_default=text(
|
|
390
|
-
onupdate=text(
|
|
354
|
+
server_default=text('GETUTCDATE()'),
|
|
355
|
+
onupdate=text('GETUTCDATE()'),
|
|
391
356
|
comment=date_updated_comment,
|
|
392
357
|
)
|
|
393
358
|
|
|
@@ -410,7 +375,7 @@ class SchemaBaseFirebird:
|
|
|
410
375
|
|
|
411
376
|
Example:
|
|
412
377
|
```python
|
|
413
|
-
from dsg_lib import base_schema
|
|
378
|
+
from dsg_lib.async_database_functions import base_schema
|
|
414
379
|
from sqlalchemy.orm import declarative_base
|
|
415
380
|
|
|
416
381
|
BASE = declarative_base()
|
|
@@ -436,8 +401,8 @@ class SchemaBaseFirebird:
|
|
|
436
401
|
date_created = Column(
|
|
437
402
|
DateTime,
|
|
438
403
|
index=True,
|
|
439
|
-
server_default=text(
|
|
440
|
-
comment=
|
|
404
|
+
server_default=text('CURRENT_TIMESTAMP'),
|
|
405
|
+
comment='Date and time when a row was inserted, defaults to current time',
|
|
441
406
|
)
|
|
442
407
|
|
|
443
408
|
# The date and time when a particular row was last updated. It defaults to
|
|
@@ -445,9 +410,9 @@ class SchemaBaseFirebird:
|
|
|
445
410
|
date_updated = Column(
|
|
446
411
|
DateTime,
|
|
447
412
|
index=True,
|
|
448
|
-
server_default=text(
|
|
449
|
-
onupdate=text(
|
|
450
|
-
comment=
|
|
413
|
+
server_default=text('CURRENT_TIMESTAMP'),
|
|
414
|
+
onupdate=text('CURRENT_TIMESTAMP'),
|
|
415
|
+
comment='Date and time when a row was last updated, defaults to current time on update',
|
|
451
416
|
)
|
|
452
417
|
|
|
453
418
|
|
|
@@ -469,7 +434,7 @@ class SchemaBaseSybase:
|
|
|
469
434
|
|
|
470
435
|
Example:
|
|
471
436
|
```python
|
|
472
|
-
from dsg_lib import base_schema
|
|
437
|
+
from dsg_lib.async_database_functions import base_schema
|
|
473
438
|
from sqlalchemy.orm import declarative_base
|
|
474
439
|
|
|
475
440
|
BASE = declarative_base()
|
|
@@ -495,7 +460,7 @@ class SchemaBaseSybase:
|
|
|
495
460
|
date_created = Column(
|
|
496
461
|
DateTime,
|
|
497
462
|
index=True,
|
|
498
|
-
server_default=text(
|
|
463
|
+
server_default=text('GETUTCDATE()'),
|
|
499
464
|
comment=date_created_comment,
|
|
500
465
|
)
|
|
501
466
|
|
|
@@ -504,8 +469,8 @@ class SchemaBaseSybase:
|
|
|
504
469
|
date_updated = Column(
|
|
505
470
|
DateTime,
|
|
506
471
|
index=True,
|
|
507
|
-
server_default=text(
|
|
508
|
-
onupdate=text(
|
|
472
|
+
server_default=text('GETUTCDATE()'),
|
|
473
|
+
onupdate=text('GETUTCDATE()'),
|
|
509
474
|
comment=date_updated_comment,
|
|
510
475
|
)
|
|
511
476
|
|
|
@@ -528,7 +493,7 @@ class SchemaBaseCockroachDB:
|
|
|
528
493
|
|
|
529
494
|
Example:
|
|
530
495
|
```python
|
|
531
|
-
from dsg_lib import base_schema
|
|
496
|
+
from dsg_lib.async_database_functions import base_schema
|
|
532
497
|
from sqlalchemy.orm import declarative_base
|
|
533
498
|
|
|
534
499
|
BASE = declarative_base()
|