arpakitlib 1.8.156__py3-none-any.whl → 1.8.157__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.
@@ -0,0 +1,11 @@
1
+ from project.core.util import setup_logging
2
+ from project.sqlalchemy_db_.sqlalchemy_db import get_cached_sqlalchemy_db
3
+
4
+
5
+ def __command():
6
+ setup_logging()
7
+ get_cached_sqlalchemy_db().remove_rows_from_tables()
8
+
9
+
10
+ if __name__ == '__main__':
11
+ __command()
@@ -220,19 +220,27 @@ class SQLAlchemyDb:
220
220
  self.remove_celery_tables_data()
221
221
  self._logger.info("all reinited")
222
222
 
223
- def remove_rows_from_tables(self):
223
+ def remove_rows_from_tables(self, exclude_tables: list[str] | None = None):
224
+ if exclude_tables is None:
225
+ exclude_tables = []
224
226
  with self.new_session() as session:
225
227
  for table_name, table in BaseDBM.metadata.tables.items():
226
- session.execute(sqlalchemy.delete(table))
228
+ if table_name not in exclude_tables:
229
+ session.execute(sqlalchemy.delete(table))
227
230
  session.commit()
228
- self._logger.info(f"rows from tables ({BaseDBM.metadata.tables.keys()}) were removed")
231
+ removed_tables = [t for t in BaseDBM.metadata.tables.keys() if t not in exclude_tables]
232
+ self._logger.info(f"rows from tables ({removed_tables}) were removed")
229
233
 
230
- async def async_remove_rows_from_tables(self):
234
+ async def async_remove_rows_from_tables(self, exclude_tables: list[str] | None = None):
235
+ if exclude_tables is None:
236
+ exclude_tables = []
231
237
  async with self.new_async_session() as async_session:
232
238
  for table_name, table in BaseDBM.metadata.tables.items():
233
- await async_session.execute(sqlalchemy.delete(table))
239
+ if table_name not in exclude_tables:
240
+ await async_session.execute(sqlalchemy.delete(table))
234
241
  await async_session.commit()
235
- self._logger.info(f"rows from tables ({BaseDBM.metadata.tables.keys()}) were removed")
242
+ removed_tables = [t for t in BaseDBM.metadata.tables.keys() if t not in exclude_tables]
243
+ self._logger.info(f"rows from tables ({removed_tables}) were removed")
236
244
 
237
245
  def check_conn(self):
238
246
  self.engine.connect()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: arpakitlib
3
- Version: 1.8.156
3
+ Version: 1.8.157
4
4
  Summary: arpakitlib
5
5
  License: Apache-2.0
6
6
  Keywords: arpakitlib,arpakit,arpakit-company,arpakitcompany,arpakit_company
@@ -53,6 +53,7 @@ arpakitlib/_arpakit_project_template_v_5/command/reinit_all_sqlalchemy_db.py,sha
53
53
  arpakitlib/_arpakit_project_template_v_5/command/reinit_json_db.py,sha256=NYY1dPVbJ_mO9aCu8VTiDT7kfloiGvG624hJ_5g2tBM,318
54
54
  arpakitlib/_arpakit_project_template_v_5/command/reinit_sqlalchemy_db.py,sha256=aCoLtUvB_dubMHMGlOFgVzxkhhPAL4lHeMU0LM4CBCs,343
55
55
  arpakitlib/_arpakit_project_template_v_5/command/remove_operations.py,sha256=l1BMAT9kQMy_aZ2ZNc20vTi1xXktmDrJvKDvo85b8xA,326
56
+ arpakitlib/_arpakit_project_template_v_5/command/remove_rows_from_tables_sqlalchemy_db.py,sha256=9XDeYhjdELLq1T7ArskaMjzqpGerYuP38PjOwUFDnqQ,259
56
57
  arpakitlib/_arpakit_project_template_v_5/command/remove_story_logs.py,sha256=l-whsYahKY6ssk-c24ufiybF-U24iFqMdkNlnlASm2U,498
57
58
  arpakitlib/_arpakit_project_template_v_5/command/rm_all_records_in_json_db.py,sha256=qF5c_Aso7XpNcBZOInz7MWXX9Wm8L73rcOZBKGXlFfg,326
58
59
  arpakitlib/_arpakit_project_template_v_5/command/set_tg_bot_commands.py,sha256=6HbuL6acw-U8vkUdqLVIEffe_FcBsDWRKZ90AakZbv8,456
@@ -402,13 +403,13 @@ arpakitlib/ar_schedule_uust_api_client_util.py,sha256=rXI2_3OTaIBgR-GixM1Ti-Ue1f
402
403
  arpakitlib/ar_settings_util.py,sha256=Y5wi_cmsjDjfJpM0VJHjbo0NoVPKfypKaD1USowwDtQ,1327
403
404
  arpakitlib/ar_sleep_util.py,sha256=ggaj7ML6QK_ADsHMcyu6GUmUpQ_9B9n-SKYH17h-9lM,1045
404
405
  arpakitlib/ar_sqladmin_util.py,sha256=Jd33EX_fAso4bvrcDhNEYOUlUHkudbadNGOJDg7rqhQ,301
405
- arpakitlib/ar_sqlalchemy_util.py,sha256=J8AAPT0BgrrRYYkJJn_ezEla6YyF3OL34Q-DNpadziU,11285
406
+ arpakitlib/ar_sqlalchemy_util.py,sha256=w_tGPTWIMVjHkTEYo9tVe1sfK_4vvfd3zGATLiYC2J4,11775
406
407
  arpakitlib/ar_ssh_runner_util.py,sha256=yvAwza480MkHKvLkDEsR7JNh2bYNs6P9rCVo4NA85NE,6865
407
408
  arpakitlib/ar_str_util.py,sha256=2lGpnXDf2h1cBZpVf5i1tX_HCv5iBd6IGnrCw4QWWlY,4350
408
409
  arpakitlib/ar_type_util.py,sha256=Cs_tef-Fc5xeyAF54KgISCsP11NHyzIsglm4S3Xx7iM,4049
409
410
  arpakitlib/ar_yookassa_api_client_util.py,sha256=VozuZeCJjmLd1zj2BdC9WfiAQ3XYOrIMsdpNK-AUlm0,5347
410
- arpakitlib-1.8.156.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
411
- arpakitlib-1.8.156.dist-info/METADATA,sha256=w7-HsemfipWlnRI-TBdYbQY3yqWzPO7mHUBd3iuBZYI,3706
412
- arpakitlib-1.8.156.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
413
- arpakitlib-1.8.156.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
414
- arpakitlib-1.8.156.dist-info/RECORD,,
411
+ arpakitlib-1.8.157.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
412
+ arpakitlib-1.8.157.dist-info/METADATA,sha256=JrajnfsEw_XyxLDxB-5qvd1cjf6LQSaVCmjGtjBahyQ,3706
413
+ arpakitlib-1.8.157.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
414
+ arpakitlib-1.8.157.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
415
+ arpakitlib-1.8.157.dist-info/RECORD,,