database-postgresql-local 0.1.1__tar.gz → 0.1.2.1234__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.
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/PKG-INFO +1 -1
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local/src/generic_crud_postgresql.py +19 -11
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local/src/utils.py +1 -1
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local.egg-info/PKG-INFO +1 -1
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/setup.py +1 -1
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/README.md +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local/src/__init__.py +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local/src/connector.py +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local/src/constants_src.py +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local/src/cursor.py +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local/src/table_columns.py +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local/src/table_definition.py +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local.egg-info/SOURCES.txt +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local.egg-info/dependency_links.txt +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local.egg-info/requires.txt +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/database_postgresql_local.egg-info/top_level.txt +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/pyproject.toml +0 -0
- {database_postgresql_local-0.1.1 → database_postgresql_local-0.1.2.1234}/setup.cfg +0 -0
|
@@ -16,7 +16,7 @@ from .cursor import Cursor
|
|
|
16
16
|
from .table_definition import table_definition
|
|
17
17
|
from .utils import (detect_if_is_test_data, generate_id_column_name,
|
|
18
18
|
generate_table_name, generate_view_name,
|
|
19
|
-
|
|
19
|
+
get_entity_type_id_by_table_name, get_where_params,
|
|
20
20
|
process_insert_data_dict, process_update_data_dict,
|
|
21
21
|
process_upsert_data_dict,
|
|
22
22
|
replace_view_with_table, validate_none_select_table_name,
|
|
@@ -31,7 +31,7 @@ from .utils import (detect_if_is_test_data, generate_id_column_name,
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
class GenericCrudPostgresql(GenericCrudAbstract, metaclass=ABCMetaLogger,
|
|
34
|
-
|
|
34
|
+
object=CRUD_POSTGRESQL_CODE_LOGGER_OBJECT):
|
|
35
35
|
"""A class that provides generic CRUD functionality for PostgreSQL databases.
|
|
36
36
|
There are 4 main functions to create, read, update, and delete data from the database.
|
|
37
37
|
The rest of the functions are helper functions or wrappers around the main functions."""
|
|
@@ -51,10 +51,13 @@ class GenericCrudPostgresql(GenericCrudAbstract, metaclass=ABCMetaLogger,
|
|
|
51
51
|
self.connection = Connector.connect(schema_name=default_schema_name)
|
|
52
52
|
self._cursor = self.connection.cursor()
|
|
53
53
|
self.default_table_name = default_table_name or generate_table_name(default_schema_name)
|
|
54
|
-
self.default_view_table_name = default_view_table_name
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
self.
|
|
54
|
+
self.default_view_table_name = default_view_table_name \
|
|
55
|
+
or generate_view_name(
|
|
56
|
+
self.default_table_name)
|
|
57
|
+
self.default_column_name = default_column_name \
|
|
58
|
+
or generate_id_column_name(self.default_table_name)
|
|
59
|
+
self.default_view_with_deleted_and_test_data = \
|
|
60
|
+
default_view_with_deleted_and_test_data
|
|
58
61
|
self.default_select_clause_value = default_select_clause_value
|
|
59
62
|
self.default_where = default_where
|
|
60
63
|
self.is_test_data = is_test_data or detect_if_is_test_data()
|
|
@@ -75,7 +78,8 @@ class GenericCrudPostgresql(GenericCrudAbstract, metaclass=ABCMetaLogger,
|
|
|
75
78
|
object={"data_dict": data_dict})
|
|
76
79
|
|
|
77
80
|
data_dict = self.__add_create_updated_user_profile_ids(
|
|
78
|
-
data_dict=data_dict, add_created_user_id=True,
|
|
81
|
+
data_dict=data_dict, add_created_user_id=True,
|
|
82
|
+
schema_name=schema_name, table_name=table_name)
|
|
79
83
|
|
|
80
84
|
columns, values, params = process_insert_data_dict(data_dict=data_dict)
|
|
81
85
|
|
|
@@ -127,8 +131,9 @@ class GenericCrudPostgresql(GenericCrudAbstract, metaclass=ABCMetaLogger,
|
|
|
127
131
|
def __get_existing_duplicate_id_with_undelete(
|
|
128
132
|
self, schema_name: str, table_name: str, data_dict: dict) -> int | None:
|
|
129
133
|
column_name = generate_id_column_name(table_name)
|
|
130
|
-
where, params = self.get_constraint_where_clause(
|
|
131
|
-
|
|
134
|
+
where, params = self.get_constraint_where_clause(
|
|
135
|
+
schema_name=schema_name, table_name=table_name,
|
|
136
|
+
data_dict=data_dict)
|
|
132
137
|
row = self.select_one_tuple_by_where(
|
|
133
138
|
schema_name=schema_name, view_table_name=table_name,
|
|
134
139
|
select_clause_value=f"{column_name}, end_timestamp",
|
|
@@ -170,9 +175,11 @@ class GenericCrudPostgresql(GenericCrudAbstract, metaclass=ABCMetaLogger,
|
|
|
170
175
|
existing_duplicate_id = None
|
|
171
176
|
else:
|
|
172
177
|
existing_duplicate_id = self.select_one_value_by_where(
|
|
173
|
-
schema_name=schema_name, view_table_name=table_name,
|
|
178
|
+
schema_name=schema_name, view_table_name=table_name,
|
|
179
|
+
select_clause_value=column_name,
|
|
174
180
|
where=where, params=params)
|
|
175
181
|
return existing_duplicate_id
|
|
182
|
+
|
|
176
183
|
def update_by_column_and_value(
|
|
177
184
|
self, *, schema_name: str = None, table_name: str = None,
|
|
178
185
|
column_name: str = None, column_value: Any,
|
|
@@ -257,6 +264,7 @@ class GenericCrudPostgresql(GenericCrudAbstract, metaclass=ABCMetaLogger,
|
|
|
257
264
|
self.connection.commit()
|
|
258
265
|
updated_rows = self.cursor.get_affected_row_count()
|
|
259
266
|
return updated_rows
|
|
267
|
+
|
|
260
268
|
def update_by_column_and_value(
|
|
261
269
|
self, *, schema_name: str = None, table_name: str = None,
|
|
262
270
|
column_name: str = None, column_value: Any,
|
|
@@ -851,7 +859,7 @@ class GenericCrudPostgresql(GenericCrudAbstract, metaclass=ABCMetaLogger,
|
|
|
851
859
|
|
|
852
860
|
def __add_identifier(self, data_dict: dict, table_name: str) -> None:
|
|
853
861
|
# If there's an "identifier" column in the table, we want to insert a random identifier
|
|
854
|
-
identifier_entity_type_id =
|
|
862
|
+
identifier_entity_type_id = get_entity_type_id_by_table_name(table_name)
|
|
855
863
|
if not identifier_entity_type_id:
|
|
856
864
|
return
|
|
857
865
|
identifier = NumberGenerator.get_random_identifier(
|
|
@@ -82,7 +82,7 @@ def generate_view_name(table_name: str) -> str:
|
|
|
82
82
|
return f"{table_name}_view"
|
|
83
83
|
|
|
84
84
|
|
|
85
|
-
def
|
|
85
|
+
def get_entity_type_id_by_table_name(table_name: str) -> int:
|
|
86
86
|
"""Gets the entity type ID for a table."""
|
|
87
87
|
# This would be implemented based on your entity type mapping
|
|
88
88
|
return None
|
|
@@ -24,7 +24,7 @@ setuptools.setup(
|
|
|
24
24
|
name=PACKAGE_NAME,
|
|
25
25
|
# Increase this number every time you make a change you
|
|
26
26
|
# want to publish. After 0.0.9 switch to 0.0.10 and not 0.1.0
|
|
27
|
-
version='0.1.
|
|
27
|
+
version='0.1.2.1234', # https://pypi.org/project/database-postgresql-local/
|
|
28
28
|
author="Circles",
|
|
29
29
|
author_email="info@circlez.ai",
|
|
30
30
|
description=f"PyPI Package for Circles {PACKAGE_NAME} Python",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|