py2ls 0.1.4.8__tar.gz → 0.1.5.0__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.
Files changed (136) hide show
  1. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/PKG-INFO +1 -1
  2. py2ls-0.1.5.0/py2ls/.git/COMMIT_EDITMSG +1 -0
  3. py2ls-0.1.5.0/py2ls/.git/FETCH_HEAD +1 -0
  4. py2ls-0.1.5.0/py2ls/.git/index +0 -0
  5. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/logs/HEAD +3 -0
  6. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/logs/refs/heads/main +3 -0
  7. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/logs/refs/remotes/origin/HEAD +5 -0
  8. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/logs/refs/remotes/origin/main +3 -0
  9. py2ls-0.1.5.0/py2ls/.git/objects/01/d5bd8065e6860c0bd23ff9fa57161806a099e1 +0 -0
  10. py2ls-0.1.5.0/py2ls/.git/objects/09/08da26de58c114225ad81f484b80bf5d351b34 +0 -0
  11. py2ls-0.1.5.0/py2ls/.git/objects/1c/3f92adda34344bcbbbf9d409c79855ae2aaea8 +2 -0
  12. py2ls-0.1.5.0/py2ls/.git/objects/32/fd627b62fad7cf3b2f9e34ab9777126a0987ad +0 -0
  13. py2ls-0.1.5.0/py2ls/.git/objects/39/7ead045fbbcfb17c62019eb18fe21ed05dbee5 +0 -0
  14. py2ls-0.1.5.0/py2ls/.git/objects/4f/7afb40dff2153d857fc85748c2eecb85125042 +0 -0
  15. py2ls-0.1.5.0/py2ls/.git/objects/62/4488173ed2c8936fa5cea3cf5dd3f26a30b86e +0 -0
  16. py2ls-0.1.5.0/py2ls/.git/objects/6d/ee29dbdcc84edeeacede105110446f3ccac963 +0 -0
  17. py2ls-0.1.5.0/py2ls/.git/objects/b7/2c9e75ab7d0afe594664650aa8f6c772f5ac64 +0 -0
  18. py2ls-0.1.5.0/py2ls/.git/objects/bb/81ccc0513f18fc160b54a82861e9a80d23f4f6 +0 -0
  19. py2ls-0.1.5.0/py2ls/.git/objects/cd/822b3574a88ebdd1ed82fd6983f37e626d52b4 +0 -0
  20. py2ls-0.1.5.0/py2ls/.git/objects/d8/4688b54c0040a30976b3a6540bc47adf7ce680 +0 -0
  21. py2ls-0.1.5.0/py2ls/.git/objects/f1/e50757fddc28b445545dc7e2759b54cdd0f42e +0 -0
  22. py2ls-0.1.5.0/py2ls/.git/refs/heads/main +1 -0
  23. py2ls-0.1.5.0/py2ls/.git/refs/remotes/origin/main +1 -0
  24. py2ls-0.1.5.0/py2ls/__init__.py +6 -0
  25. py2ls-0.1.5.0/py2ls/data/.DS_Store +0 -0
  26. py2ls-0.1.5.0/py2ls/data/db2ls_sql_chtsht.json +39 -0
  27. py2ls-0.1.5.0/py2ls/data/lang_code_iso639.json +97 -0
  28. py2ls-0.1.5.0/py2ls/db2ls.py +356 -0
  29. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/ips.py +160 -1190
  30. py2ls-0.1.5.0/py2ls/stats.py +810 -0
  31. py2ls-0.1.5.0/py2ls/stdshade.py +173 -0
  32. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/translator.py +6 -99
  33. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/pyproject.toml +1 -1
  34. py2ls-0.1.4.8/py2ls/.git/COMMIT_EDITMSG +0 -1
  35. py2ls-0.1.4.8/py2ls/.git/FETCH_HEAD +0 -1
  36. py2ls-0.1.4.8/py2ls/.git/index +0 -0
  37. py2ls-0.1.4.8/py2ls/.git/refs/heads/main +0 -1
  38. py2ls-0.1.4.8/py2ls/.git/refs/remotes/origin/main +0 -1
  39. py2ls-0.1.4.8/py2ls/__init__.py +0 -16
  40. py2ls-0.1.4.8/py2ls/dbhandler.py +0 -97
  41. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/README.md +0 -0
  42. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.DS_Store +0 -0
  43. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/HEAD +0 -0
  44. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/config +0 -0
  45. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/description +0 -0
  46. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/applypatch-msg.sample +0 -0
  47. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/commit-msg.sample +0 -0
  48. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/fsmonitor-watchman.sample +0 -0
  49. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/post-update.sample +0 -0
  50. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/pre-applypatch.sample +0 -0
  51. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/pre-commit.sample +0 -0
  52. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/pre-merge-commit.sample +0 -0
  53. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/pre-push.sample +0 -0
  54. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/pre-rebase.sample +0 -0
  55. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/pre-receive.sample +0 -0
  56. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/prepare-commit-msg.sample +0 -0
  57. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/push-to-checkout.sample +0 -0
  58. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/hooks/update.sample +0 -0
  59. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/info/exclude +0 -0
  60. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/0b/409e1bc918277010f5679b402d1d1dda53e15c +0 -0
  61. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/14/449a0e6ba4ea2f1a73acf63ef91c9c6193f9ed +0 -0
  62. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/15/a8e468aacfcb440e090020f36d0b985d45da23 +0 -0
  63. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/1a/b4585881a6a42889f01aa0cfe25fd5acfaf46f +0 -0
  64. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/1d/fe9d9633b24ea560354f4f93d39c6e5f163ea0 +0 -0
  65. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/24/6b368b986f758630c46dc02b7fa512b53422f7 +0 -0
  66. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/25/b796accd261b9135fd32a2c00785f68edf6c46 +0 -0
  67. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/30/a2f8da47ee947811dc8d993f5a06a45de374f4 +0 -0
  68. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/36/b4a1b7403abc6c360f8fe2cb656ab945254971 +0 -0
  69. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/36/e56a361f526eafa59c5235a5c990bf288b5f9c +0 -0
  70. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/36/ef43e50009e59db11812c258846d9e38718173 +0 -0
  71. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/3b/bd972aa7ad680858f8dfbd0f7fcd97756f0d6f +0 -0
  72. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/3c/bbe5f4173d165127b9ad96119f1ec24c306ffc +0 -0
  73. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/3f/d6561300938afbb3d11976cf9c8f29549280d9 +0 -0
  74. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/43/dbd49b2ee367c5434dd545e3b5795434f2ef0b +0 -0
  75. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/48/a88fc5806305d0bb0755ee6801161b79696972 +0 -0
  76. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/50/08ddfcf53c02e82d7eee2e57c38e5672ef89f6 +0 -0
  77. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/53/e0deb1cb4c2c606bced6e7f9a66b0fda60980d +0 -0
  78. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/56/e4e8b2d5545e0256090f45aa8fc42c5fe067d0 +0 -0
  79. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/58/20a729045d4dc7e37ccaf8aa8eec126850afe2 +0 -0
  80. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/60/f273eb1c412d916fa3f11318a7da7a9911b52a +0 -0
  81. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/61/570cec8c061abe74121f27f5face6c69b98f99 +0 -0
  82. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/62/7c81b23b4e56e87b042b650b0103653cc9e34a +0 -0
  83. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/62/d90ccf8cbefdc2e4fd475e7c6f4f76e9fdf801 +0 -0
  84. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/64/27a4edff08f93d98f511418423f09f2ab90bcd +0 -0
  85. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/69/13c452ca319f7cbf6a0836dc10a5bb033c84e4 +0 -0
  86. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/6a/52e747a2b349b128d1490d9e896d2323818eb7 +0 -0
  87. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/6b/7fde264d93a7a0986d394c46c7650d0ce2ab92 +0 -0
  88. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/6c/cebb29b7f3f5b0c889f6dadbf9ff066554587d +0 -0
  89. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/71/36b2074a2754be8b58127d82250e5b37e3c373 +0 -0
  90. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/78/3d4167bc95c9d2175e0df03ef1c1c880ba75ab +0 -0
  91. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/79/7ae089b2212a937840e215276005ce76881307 +0 -0
  92. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/7e/5956c806b5edc344d46dab599dec337891ba1f +0 -0
  93. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/81/8f26b7bf042269729020cf944fc362d66ba27e +0 -0
  94. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/84/59071b722a255b774a80b27746033f8141ab39 +0 -0
  95. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/87/ef1fc3f7f1ddc4d0ab9b3e65381ce9f3388621 +0 -0
  96. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/8b/84f56978e1de8f2ae82abce5f8b3e182d365cd +0 -0
  97. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/8e/55a7d2b96184030211f20c9b9af201eefcac82 +0 -0
  98. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/91/c69ad88fe0ba94aa7859fb5f7edac5e6f1a3f7 +0 -0
  99. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/9d/0df52899fe95279059286d9c0ec42287edc168 +0 -0
  100. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/a5/ec8f74642fbba27f7ea78c53b372ae0c7dedce +0 -0
  101. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/a7/3e13eafee65c5b8d73ad2d3ea46d0eee82f0d3 +0 -0
  102. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/b0/56be4be89ba6b76949dd641df45bb7036050c8 +0 -0
  103. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/b0/9cd7856d58590578ee1a4f3ad45d1310a97f87 +0 -0
  104. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/b2/18e6a0f0f1c4df8cdefa9852058348abc713b7 +0 -0
  105. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/b5/61831c7dce8ea51e7ee6b6fa35745f14d8242d +0 -0
  106. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/bb/934eb33bc1a8b85630bf680caffd99560c1b8f +0 -0
  107. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/c1/20fc812b9ad311c34a3608512d6a9d976bb48e +0 -0
  108. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/c4/cba65f1163661999ee4b8ed23342b63bc1300c +0 -0
  109. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/c6/7f17e5707313600efcb85e9a3fedea35dba591 +0 -0
  110. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/cf/0c0d9c6fb09473aaeb7f7e2edbd770c3f2ef3d +0 -0
  111. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/d6/9ab1c4aadf279936dd778e8346ba60f74705b6 +0 -0
  112. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/d9/005f2cc7fc4e65f14ed5518276007c08cf2fd0 +0 -0
  113. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/d9/c2403fd166ce791b4e9d0c6792ed8342c71fcd +0 -0
  114. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/d9/dfa5aee51e92a541b707e8e7baea6f06deff98 +0 -0
  115. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/db/141dbaa93594df2a8156182f361ee4db829359 +0 -0
  116. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/db/ffa8ea7bda721d0cee7b9e4ce5b2ef927733ff +0 -0
  117. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/df/e0770424b2a19faf507a501ebfc23be8f54e7b +0 -0
  118. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/e3/1356f90ea6dd0577b5e0b40b206319adcbf085 +0 -0
  119. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/e3/5a4dafc50850cacac7bf76c56db2715cbda2c4 +0 -0
  120. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/e9/391ffe371f1cc43b42ef09b705d9c767c2e14f +0 -0
  121. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/f4/b64d3107b39e3ad6f540c6607004ea34e6c024 +0 -0
  122. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/f7/c98ba5c2f903e603b1f5e63d49fbc8a43815cc +0 -0
  123. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/fa/147e6bb78a2e8db241d231295fd7f1ed061af8 +0 -0
  124. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/objects/fc/292e793ecfd42240ac43be407023bd731fa9e7 +0 -0
  125. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.git/refs/remotes/origin/HEAD +0 -0
  126. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.gitattributes +0 -0
  127. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/.gitignore +0 -0
  128. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/LICENSE +0 -0
  129. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/README.md +0 -0
  130. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/brain_atlas.py +0 -0
  131. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/correlators.py +0 -0
  132. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/freqanalysis.py +0 -0
  133. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/netfinder.py +0 -0
  134. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/setuptools-70.1.0-py3-none-any.whl +0 -0
  135. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/sleep_events_detectors.py +0 -0
  136. {py2ls-0.1.4.8 → py2ls-0.1.5.0}/py2ls/wb_detector.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py2ls
3
- Version: 0.1.4.8
3
+ Version: 0.1.5.0
4
4
  Summary: py(thon)2(too)ls
5
5
  Author: Jianfeng
6
6
  Author-email: Jianfeng.Liu0413@gmail.com
@@ -0,0 +1 @@
1
+ Delete dbhandler.py
@@ -0,0 +1 @@
1
+ 1c3f92adda34344bcbbbf9d409c79855ae2aaea8 branch 'main' of https://github.com/Jianfengliu0413/py2ls
Binary file
@@ -13,3 +13,6 @@ d9dfa5aee51e92a541b707e8e7baea6f06deff98 e31356f90ea6dd0577b5e0b40b206319adcbf08
13
13
  e31356f90ea6dd0577b5e0b40b206319adcbf085 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng <Jianfeng.Liu0413@gmail.com> 1718619568 +0200 commit: Update ips.py
14
14
  1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 627c81b23b4e56e87b042b650b0103653cc9e34a Jianfeng <Jianfeng.Liu0413@gmail.com> 1718698925 +0200 commit: update xample_imgsets
15
15
  627c81b23b4e56e87b042b650b0103653cc9e34a c120fc812b9ad311c34a3608512d6a9d976bb48e Jianfeng <Jianfeng.Liu0413@gmail.com> 1718893141 +0200 commit: update
16
+ c120fc812b9ad311c34a3608512d6a9d976bb48e d84688b54c0040a30976b3a6540bc47adf7ce680 Jianfeng <Jianfeng.Liu0413@gmail.com> 1720605394 +0200 commit: update ips
17
+ d84688b54c0040a30976b3a6540bc47adf7ce680 32fd627b62fad7cf3b2f9e34ab9777126a0987ad Jianfeng <Jianfeng.Liu0413@gmail.com> 1720708531 +0200 commit: translator update
18
+ 32fd627b62fad7cf3b2f9e34ab9777126a0987ad 1c3f92adda34344bcbbbf9d409c79855ae2aaea8 Jianfeng <Jianfeng.Liu0413@gmail.com> 1720709655 +0200 commit: Delete dbhandler.py
@@ -13,3 +13,6 @@ d9dfa5aee51e92a541b707e8e7baea6f06deff98 e31356f90ea6dd0577b5e0b40b206319adcbf08
13
13
  e31356f90ea6dd0577b5e0b40b206319adcbf085 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng <Jianfeng.Liu0413@gmail.com> 1718619568 +0200 commit: Update ips.py
14
14
  1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 627c81b23b4e56e87b042b650b0103653cc9e34a Jianfeng <Jianfeng.Liu0413@gmail.com> 1718698925 +0200 commit: update xample_imgsets
15
15
  627c81b23b4e56e87b042b650b0103653cc9e34a c120fc812b9ad311c34a3608512d6a9d976bb48e Jianfeng <Jianfeng.Liu0413@gmail.com> 1718893141 +0200 commit: update
16
+ c120fc812b9ad311c34a3608512d6a9d976bb48e d84688b54c0040a30976b3a6540bc47adf7ce680 Jianfeng <Jianfeng.Liu0413@gmail.com> 1720605394 +0200 commit: update ips
17
+ d84688b54c0040a30976b3a6540bc47adf7ce680 32fd627b62fad7cf3b2f9e34ab9777126a0987ad Jianfeng <Jianfeng.Liu0413@gmail.com> 1720708531 +0200 commit: translator update
18
+ 32fd627b62fad7cf3b2f9e34ab9777126a0987ad 1c3f92adda34344bcbbbf9d409c79855ae2aaea8 Jianfeng <Jianfeng.Liu0413@gmail.com> 1720709655 +0200 commit: Delete dbhandler.py
@@ -36,3 +36,8 @@ e31356f90ea6dd0577b5e0b40b206319adcbf085 e31356f90ea6dd0577b5e0b40b206319adcbf08
36
36
  1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng Liu <macjianfeng@JFLMBP.local> 1718707170 +0200 remote set-head
37
37
  1ab4585881a6a42889f01aa0cfe25fd5acfaf46f 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng Liu <macjianfeng@JFLMBP.local> 1718708982 +0200 remote set-head
38
38
  c120fc812b9ad311c34a3608512d6a9d976bb48e c120fc812b9ad311c34a3608512d6a9d976bb48e Jianfeng Liu <macjianfeng@JFLMBP.cin.medizin.uni-tuebingen.de> 1718893145 +0200 remote set-head
39
+ c120fc812b9ad311c34a3608512d6a9d976bb48e c120fc812b9ad311c34a3608512d6a9d976bb48e Jianfeng Liu <macjianfeng@JFLMBP.cin.medizin.uni-tuebingen.de> 1720605735 +0200 remote set-head
40
+ d84688b54c0040a30976b3a6540bc47adf7ce680 d84688b54c0040a30976b3a6540bc47adf7ce680 Jianfeng Liu <macjianfeng@JFLMBP.cin.medizin.uni-tuebingen.de> 1720605738 +0200 remote set-head
41
+ d84688b54c0040a30976b3a6540bc47adf7ce680 d84688b54c0040a30976b3a6540bc47adf7ce680 Jianfeng Liu <macjianfeng@JFLMBP.cin.medizin.uni-tuebingen.de> 1720708526 +0200 remote set-head
42
+ 32fd627b62fad7cf3b2f9e34ab9777126a0987ad 32fd627b62fad7cf3b2f9e34ab9777126a0987ad Jianfeng Liu <macjianfeng@JFLMBP.cin.medizin.uni-tuebingen.de> 1720708535 +0200 remote set-head
43
+ 1c3f92adda34344bcbbbf9d409c79855ae2aaea8 1c3f92adda34344bcbbbf9d409c79855ae2aaea8 Jianfeng Liu <macjianfeng@JFLMBP.cin.medizin.uni-tuebingen.de> 1720709658 +0200 remote set-head
@@ -12,3 +12,6 @@ cf0c0d9c6fb09473aaeb7f7e2edbd770c3f2ef3d 6427a4edff08f93d98f511418423f09f2ab90bc
12
12
  d9dfa5aee51e92a541b707e8e7baea6f06deff98 e31356f90ea6dd0577b5e0b40b206319adcbf085 Jianfeng <Jianfeng.Liu0413@gmail.com> 1718618415 +0200 update by push
13
13
  e31356f90ea6dd0577b5e0b40b206319adcbf085 1ab4585881a6a42889f01aa0cfe25fd5acfaf46f Jianfeng <Jianfeng.Liu0413@gmail.com> 1718619570 +0200 update by push
14
14
  1ab4585881a6a42889f01aa0cfe25fd5acfaf46f c120fc812b9ad311c34a3608512d6a9d976bb48e Jianfeng <Jianfeng.Liu0413@gmail.com> 1718893144 +0200 update by push
15
+ c120fc812b9ad311c34a3608512d6a9d976bb48e d84688b54c0040a30976b3a6540bc47adf7ce680 Jianfeng <Jianfeng.Liu0413@gmail.com> 1720605737 +0200 update by push
16
+ d84688b54c0040a30976b3a6540bc47adf7ce680 32fd627b62fad7cf3b2f9e34ab9777126a0987ad Jianfeng <Jianfeng.Liu0413@gmail.com> 1720708534 +0200 update by push
17
+ 32fd627b62fad7cf3b2f9e34ab9777126a0987ad 1c3f92adda34344bcbbbf9d409c79855ae2aaea8 Jianfeng <Jianfeng.Liu0413@gmail.com> 1720709657 +0200 update by push
@@ -0,0 +1,2 @@
1
+ x��A
2
+ �0E]�� e2i2
@@ -0,0 +1 @@
1
+ 1c3f92adda34344bcbbbf9d409c79855ae2aaea8
@@ -0,0 +1 @@
1
+ 1c3f92adda34344bcbbbf9d409c79855ae2aaea8
@@ -0,0 +1,6 @@
1
+ """
2
+ __init__ of the pyos module
3
+ """
4
+ from .ips import *
5
+ from.translator import *
6
+ from .netfinder import *
Binary file
@@ -0,0 +1,39 @@
1
+ {
2
+ "having":"SELECT column_name(s) FROM table_name GROUP BY column_name(s) HAVING condition\n\nSELECT DEP_ID, COUNT(*) AS 'NUM_EMPLOYEES', AVG(SALARY) AS 'AVG_SALARY' FROM EMPLOYEES GROUP BY DEP_ID HAVING count(*) < 4 ORDER BY AVG_SALARY;\n\nHAVING clause is used in conjunction with GROUP BY clause in collaboration with the SELECT statement in order to filter the data as per the given condition and then group as per identical values of a specified parameter.",
3
+ "group by":"SELECT column_name(s) FROM table_name GROUP BY column_name(s)\n\nSELECT dep_id, COUNT(*) FROM employees GROUP BY dep_id; \n\nThis returns the department IDs and the number of employees in them, grouped by the department IDs.\n\nGROUP BY clause is used in collaboration with the SELECT statement to arrange data with identical values into groups.",
4
+ "ORDER BY":"SELECT column1, column2, ... \nFROM table_name ORDER BY column1, column2, ... \nASC|DESC;\n\nSELECT f_name, l_name, dep_id FROM employees ORDER BY dep_id DESC, l_name;\n\nThis displays the first name, last name, and department ID of employees, first sorted in descending order of department IDs and then sorted alphabetically as per their last names.\n\nORDER BY keyword is used to sort the result-set in ascending or descending order. The default is ascending. In case of multiple columns in ORDER BY, the sorting will be done in the sequence of the appearance of the arguments.",
5
+ "between":"SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2;\n\nSELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2;\nThis generates all records of employees with salaries between 40000 and 80000.\n\nThe BETWEEN operator selects values within a given range. The values can be numbers, text, or dates. The BETWEEN operator is inclusive: begin and end values are included.",
6
+ "like":"SELECT column1, column2, ... \nFROM table_name WHERE columnN LIKE pattern;\n\nSELECT f_name , l_name FROM employees WHERE address LIKE '%Elgin,IL%';\n\n LIKE operator is used in a WHERE clause to search for a specified pattern in a column.\n\n ",
7
+ "connect":"Create a new database and open a database connection to allow sqlite3 to work with it. Call sqlite3.connect() to create a connection to the database INSTRUCTOR.db in the current working directory, implicitly creating it if it does not exist.\n\nsqlite3.connect()\n\ncon = sqlite3.connect('INSTRUCTOR.db')",
8
+ "cursor":"To execute SQL statements and fetch results from SQL queries, use a database cursor. Call con.cursor() to create the Cursor.\n\ncon.cursor()\n\ncursor_obj = con.cursor()",
9
+ "execute":"The execute method in Python's SQLite library allows to perform SQL commands, including retrieving data from a table using a query like 'Select * from table_name.' When you execute this command, the result is obtained as a collection of table data stored in an object, typically in the form of a list of lists.\n\nThe execute method in Python's SQLite library allows to perform SQL commands, including retrieving data from a table using a query like 'Select * from table_name.' When you execute this command, the result is obtained as a collection of table data stored in an object, typically in the form of a list of lists.",
10
+ "fetchall":"The fetchall() method in Python retrieves all the rows from the result set of a query and presents them as a list of tuples.\n\nUsage:\n statement = '''SELECT * FROM INSTRUCTOR'''\ncursor_obj.execute(statement)\noutput_all = cursor_obj.fetchall()\nfor row_all in output_all:\n print(row_all)\n\nThe fetchall() method in Python retrieves all the rows from the result set of a query and presents them as a list of tuples.",
11
+ "fetchmany":"fetchmany()\n\n output_many = cursor_obj.fetchmany(2)\noutput_many = cursor_obj.fetchmany(2)\n output_many = cursor_obj.fetchmany(2)",
12
+ "read_sql_query":"read_sql_query()\n\n df = pd.read_sql_query('select * from instructor;', conn)",
13
+ "create": "CREATE TABLE table_name (\n column1 datatype PRIMARY KEY (one or more columns),\n column2 datatype,\n column3 datatype,\n ...\n);",
14
+ "count": "COUNT is a function that takes the name of a column as argument and counts the number of rows when the column is not NULL.\n\nSELECT COUNT * FROM table_name ;\n usage: \n SELECT COUNT(country) FROM placeofinterest WHERE country='Canada';",
15
+ "insert": "INSERT is used to insert new rows in the table.\n\nINSERT INTO table_name (column1, column2, column3, ...)\nVALUES (value1, value2, value3, ...);",
16
+ "select": "SELECT statement is used to fetch data from a database.\n\nSELECT column1, column2, column3, ...\nFROM table_name\nWHERE condition; \n usage:\n SELECT city FROM placeofintereste;",
17
+ "where": "WHERE clause is used to extract only those records that fulfill a specified condition.\n\nSELECT column1, column2, column3, ...\nFROM table_name\nWHERE condition; \n usage:\n SELECT city FROM placeofintereste;",
18
+ "update": "UPDATE used to update the rows in the table.\n\nUPDATE table_name\nSET column1 = value1, column2 = value2, ...\nWHERE condition;\n\nUPDATE used to update the rows in the table.",
19
+ "delete": "DELETE statement is used to remove rows from the table which are specified in the WHERE condition.\n\nDELETE FROM table_name\nWHERE condition;\n\nDELETE statement is used to remove rows from the table which are specified in the WHERE condition.",
20
+ "drop": "DROP TABLE table_name;\n\nUse the DROP TABLE statement to delete a table from a database. If you delete a table that contains data, by default the data will be deleted alongside the table.",
21
+ "alter_table_add_column": "ALTER TABLE table_name\nADD column_name datatype;",
22
+ "alter_table_rename": "ALTER TABLE table_name\nRENAME TO new_table_name;",
23
+ "create_index": "CREATE INDEX index_name\nON table_name (column1, column2, ...);",
24
+ "create_unique_index": "CREATE UNIQUE INDEX index_name\nON table_name (column1, column2, ...);",
25
+ "drop_index": "DROP INDEX index_name;",
26
+ "create_view": "CREATE VIEW view_name AS\nSELECT column1, column2, ...\nFROM table_name\nWHERE condition;",
27
+ "drop_view": "DROP VIEW view_name;",
28
+ "pragma": "PRAGMA pragma_name;",
29
+ "transaction_begin": "BEGIN TRANSACTION;",
30
+ "transaction_commit": "COMMIT;",
31
+ "transaction_rollback": "ROLLBACK;",
32
+ "attach_database": "ATTACH DATABASE 'file_path' AS database_name;",
33
+ "detach_database": "DETACH DATABASE database_name;",
34
+ "analyze": "ANALYZE table_name;",
35
+ "vacuum": "VACUUM;",
36
+ "create_trigger": "CREATE TRIGGER trigger_name\nBEFORE INSERT ON table_name\nFOR EACH ROW\nBEGIN\n -- SQL statements\nEND;",
37
+ "drop_trigger": "DROP TRIGGER trigger_name;",
38
+ "limit":"LIMIT is a clause to specify the maximum number of rows the result set must have.\n\nSELECT * FROM table_name LIMIT number;\n\nSELECT * FROM placeofinterest WHERE airport='pearson' LIMIT 5;"
39
+ }
@@ -0,0 +1,97 @@
1
+ {
2
+ "Abkhazian": "ab",
3
+ "Afar": "aa",
4
+ "Afrikaans": "af",
5
+ "Akan": "ak",
6
+ "Albanian": "sq",
7
+ "Amharic": "am",
8
+ "Arabic": "ar",
9
+ "Armenian": "hy",
10
+ "Assamese": "as",
11
+ "Aymara": "ay",
12
+ "Azerbaijani": "az",
13
+ "Bashkir": "ba",
14
+ "Basque": "eu",
15
+ "Belarusian": "be",
16
+ "Bislama": "bi",
17
+ "Breton": "br",
18
+ "Burmese": "my",
19
+ "Catalan, Valencian": "ca",
20
+ "Chamorro": "ch",
21
+ "Chichewa, Chewa, Nyanja": "ny",
22
+ "Chinese": "zh",
23
+ "Corsican": "co",
24
+ "Cree": "cr",
25
+ "Croatian": "hr",
26
+ "Danish": "da",
27
+ "Dutch, Flemish": "nl",
28
+ "Dzongkha": "dz",
29
+ "English": "en",
30
+ "Finnish": "fi",
31
+ "French": "fr",
32
+ "Galician": "gl",
33
+ "Georgian": "ka",
34
+ "German": "de",
35
+ "Greek, Modern (1453\u2013)": "el",
36
+ "Gujarati": "gu",
37
+ "Hausa": "ha",
38
+ "Hebrew": "he",
39
+ "Hindi": "hi",
40
+ "Hungarian": "hu",
41
+ "Icelandic": "is",
42
+ "Italian": "it",
43
+ "Kikuyu, Gikuyu": "ki",
44
+ "Korean": "ko",
45
+ "Kurdish": "ku",
46
+ "Latin": "la",
47
+ "Limburgan, Limburger, Limburgish": "li",
48
+ "Luba-Katanga": "lu",
49
+ "Macedonian": "mk",
50
+ "Malay": "ms",
51
+ "Nauru": "na",
52
+ "North Ndebele": "nd",
53
+ "Nepali": "ne",
54
+ "Norwegian": "no",
55
+ "Norwegian Nynorsk": "nn",
56
+ "Sichuan Yi, Nuosu": "ii",
57
+ "Occitan": "oc",
58
+ "Ojibwa": "oj",
59
+ "Oriya": "or",
60
+ "Ossetian, Ossetic": "os",
61
+ "Persian": "fa",
62
+ "Punjabi, Panjabi": "pa",
63
+ "Quechua": "qu",
64
+ "Romanian, Moldavian, Moldovan": "ro",
65
+ "Russian": "ru",
66
+ "Samoan": "sm",
67
+ "Sanskrit": "sa",
68
+ "Serbian": "sr",
69
+ "Shona": "sn",
70
+ "Sinhala, Sinhalese": "si",
71
+ "Slovenian": "sl",
72
+ "Somali": "so",
73
+ "Sundanese": "su",
74
+ "Swahili": "sw",
75
+ "Swati": "ss",
76
+ "Tajik": "tg",
77
+ "Tamil": "ta",
78
+ "Telugu": "te",
79
+ "Thai": "th",
80
+ "Tibetan": "bo",
81
+ "Tigrinya": "ti",
82
+ "Tonga (Tonga Islands)": "to",
83
+ "Tsonga": "ts",
84
+ "Twi": "tw",
85
+ "Ukrainian": "uk",
86
+ "Urdu": "ur",
87
+ "Uzbek": "uz",
88
+ "Venda": "ve",
89
+ "Vietnamese": "vi",
90
+ "Volap\u00fck": "vo",
91
+ "Welsh": "cy",
92
+ "Wolof": "wo",
93
+ "Xhosa": "xh",
94
+ "Yiddish": "yi",
95
+ "Yoruba": "yo",
96
+ "Zulu": "zu"
97
+ }
@@ -0,0 +1,356 @@
1
+ import sqlite3
2
+ import pandas as pd
3
+ import json
4
+ from typing import Optional, List, Union, Tuple
5
+ import os
6
+ from pprint import pp
7
+ class db2ls:
8
+ @classmethod
9
+ def cheatsheet(cls, command: str = None, verbose:bool=False):
10
+ script_dir = os.path.dirname(__file__)
11
+ json_path = os.path.join(script_dir, "data/db2ls_sql_chtsht.json")
12
+ try:
13
+ with open(json_path) as file:
14
+ cheatsheets = json.load(file)
15
+ if command:
16
+ command_lower = command.lower()
17
+ if command_lower in cheatsheets:
18
+ print(cheatsheets[command_lower])
19
+ elif command_lower in ["list", 'all']:
20
+ pp(list(cheatsheets.keys()))
21
+ else:
22
+ print("Command not found. Available commands are: create, insert, select, update, delete, drop.")
23
+ else:
24
+ print("no 'command'")
25
+ except FileNotFoundError:
26
+ print(f"db2ls_sql_chtsht.json cannot be found at {json_path}")
27
+ if verbose:
28
+ pp(list(cheatsheets.keys()))
29
+
30
+ def __init__(self, db_path: str):
31
+ self.db_path = db_path
32
+ # # self.logger = logging.getLogger(__name__)
33
+ self.connection: Optional[sqlite3.Connection] = None
34
+ def __enter__(self) -> 'db2ls':
35
+ """
36
+ Establishes a context for the db2ls object, opening a connection to the database.
37
+ This method is automatically called when entering a 'with' statement.
38
+ """
39
+ self.connection = sqlite3.connect(self.db_path)
40
+ return self
41
+
42
+ def __exit__(self, exc_type, exc_val, exc_tb) -> None:
43
+ # Closes the database connection when exiting a 'with' statement.
44
+ if self.connection:
45
+ self.connection.close()
46
+ print("Connection closed")
47
+
48
+ @classmethod
49
+ def connect(cls, db_path: str) -> 'db2ls':
50
+ instance = cls(db_path)
51
+ instance.connection = sqlite3.connect(db_path)
52
+ return instance
53
+
54
+ def execute(self, query: str, params: Optional[Tuple] = None) -> None:
55
+ # Execute a SQL query with optional parameters.
56
+ try:
57
+ with self.connection as conn:
58
+ cursor = conn.cursor()
59
+ if params:
60
+ cursor.execute(query, params)
61
+ else:
62
+ cursor.execute(query)
63
+ conn.commit()
64
+ # self.log_change('EXECUTE', query, params)
65
+ # print("Query executed successfully.")
66
+ except sqlite3.Error as e:
67
+ print(f"Error executing query: {e}")
68
+ pass
69
+
70
+ def tables(self) -> List[str]:
71
+ # Retrieve the names of all tables in the database.
72
+ query = "SELECT name FROM sqlite_master WHERE type='table';"
73
+ rows = self.fetchall(query)
74
+ if rows:
75
+ tab_= [row[0] for row in rows]
76
+ else:
77
+ tab_= []
78
+ if len(tab_)==1:
79
+ return tab_[0]
80
+ else:
81
+ return tab_
82
+
83
+ def fetchall(self, query: str, params: Optional[Tuple] = None) -> Optional[List[Tuple]]:
84
+ # Execute a SQL query and return all results.
85
+ try:
86
+ with self.connection as conn:
87
+ cursor = conn.cursor()
88
+ if params:
89
+ cursor.execute(query, params)
90
+ else:
91
+ cursor.execute(query)
92
+ rows = cursor.fetchall()
93
+ return rows
94
+ except sqlite3.Error as e:
95
+ print(f"Error executing query: {e}")
96
+ return None
97
+
98
+ def fetchmany(self, query: str, params: Optional[Tuple] = None,n:int=5) -> Optional[List[Tuple]]:
99
+ # Execute a SQL query and return all results.
100
+ try:
101
+ with self.connection as conn:
102
+ cursor = conn.cursor()
103
+ if params:
104
+ cursor.execute(query, params)
105
+ else:
106
+ cursor.execute(query)
107
+ rows = cursor.fetchmany(n)
108
+ return rows
109
+ except sqlite3.Error as e:
110
+ print(f"Error executing query: {e}")
111
+ return None
112
+
113
+ def create(self, table: str,columns:Union[str, List[str]],exist_ok:bool=True) -> None:
114
+ # Create a table in the database.
115
+ if isinstance(columns, list):
116
+ columns_=', '.join(columns)
117
+ else:
118
+ columns_=columns
119
+ if exist_ok:
120
+ query = f"CREATE TABLE IF NOT EXISTS {table} ({columns_})"
121
+ else:
122
+ query = f"CREATE TABLE {table} ({columns_})"
123
+ self.execute(query)
124
+ print(f"Table created with definition: {query}")
125
+
126
+ def insert(self, table: str = None, columns: List[str] = None, data: List[Union[str, int, float]] = None) -> None:
127
+ if table is None:
128
+ if isinstance(self.tables(),list):
129
+ table=self.tables()[0]
130
+ else:
131
+ table=self.tables()
132
+ # Insert data into a table.
133
+ placeholders = ', '.join(['?' for _ in data])
134
+ query = f"INSERT INTO {table} ({', '.join(columns)}) VALUES ({placeholders})"
135
+ self.execute(query, data)
136
+ print(f"Data inserted into {table}: {data}")
137
+
138
+ def select(self, table: str=None, columns: Union[str, List[str]] = '*', where: Optional[str] = None, where_params: Optional[Tuple] = None, verbose: bool=False) -> Optional[List[Tuple]]:
139
+ # Select data from a table.
140
+ if table is None:
141
+ if isinstance(self.tables(),list):
142
+ table=self.tables()[0]
143
+ else:
144
+ table=self.tables()
145
+ if isinstance(columns, list):
146
+ columns_=', '.join(columns)
147
+ else:
148
+ columns_=columns
149
+ query = f"SELECT {columns_} FROM {table}"
150
+ if where:
151
+ query += f" WHERE {where}"
152
+ rows = self.fetchall(query, where_params)
153
+ if verbose:
154
+ for row in rows:
155
+ print(row)
156
+ return rows
157
+
158
+ def print(self, table: str = None, columns: Union[str, List[str]] = ['*'], where: Optional[str] = None, where_params: Optional[Tuple] = None, n:int=5) -> Optional[List[Tuple]]:
159
+ if table is None:
160
+ if isinstance(self.tables(),list):
161
+ table=self.tables()[0]
162
+ else:
163
+ table=self.tables()
164
+ rows = self.select(table=table,columns=columns,where=where,where_params=where_params)
165
+ if rows:
166
+ if len(rows) <= n:
167
+ rows_=rows
168
+ else:
169
+ rows_=rows[:n]
170
+ for row in rows_:
171
+ print(row)
172
+ def update(self, table: str=None, set_clause: Union[str, List[str]] = None, where: Union[str, List[str]] = None, where_params: Tuple=None) -> None:
173
+ """
174
+ Update data in a table.
175
+ Usage:
176
+ option1:
177
+ with db2ls(db_path) as db:
178
+ db.update(table, "postcode = '72076'", "postcode = '69181'")
179
+ option2:
180
+ db2ls.connect(db_path).execute("update germany set city='Tübingen' where city = 'Leimen'")
181
+ """
182
+ if table is None:
183
+ if isinstance(self.tables(),list):
184
+ table=self.tables()[0]
185
+ else:
186
+ table=self.tables()
187
+ if isinstance(set_clause, list):
188
+ set_clause = ', '.join([f"{col} = ?" for col in set_clause])
189
+
190
+ if isinstance(where, list):
191
+ where_clause = ' AND '.join(where)
192
+ else:
193
+ where_clause = where
194
+
195
+ query = f"UPDATE {table} SET {set_clause} WHERE {where_clause}"
196
+ print(query)
197
+ if where_params is None:
198
+ self.execute(query)
199
+ # print(f"Data updated in {table} where {where_clause}")
200
+ else:
201
+ self.execute(query, where_params)
202
+ # print(f"Data updated in {table} where {where_clause}: {where_params}")
203
+
204
+ def drop(self, table:str=None):
205
+ if table is None:
206
+ if isinstance(self.tables(),list):
207
+ table=self.tables()[0]
208
+ else:
209
+ table=self.tables()
210
+ self.execute("DROP TABLE {table}")
211
+ print(f"Warning: {table} got removed from DataBase")
212
+ def remove(self, table:str=None):
213
+ self.drop(self, table)
214
+
215
+ def delete(self, table: str=None, where: str = None, where_params: Tuple = None) -> None:
216
+ # Delete data from a table.
217
+ if table is None:
218
+ if isinstance(self.tables(),list):
219
+ table=self.tables()[0]
220
+ else:
221
+ table=self.tables()
222
+ query = f"DELETE FROM {table} WHERE {where}"
223
+ self.execute(query, where_params)
224
+ print(f"Data deleted from {table} where {where}")
225
+
226
+ def begin(self) -> None:
227
+ """
228
+ Begin a transaction.
229
+ """
230
+ try:
231
+ self.connection.execute('BEGIN')
232
+ print("Transaction started")
233
+ except sqlite3.Error as e:
234
+ print(f"Error starting transaction: {e}")
235
+ pass
236
+
237
+ def commit(self) -> None:
238
+ """
239
+ Commit the current transaction.
240
+ """
241
+ try:
242
+ self.connection.commit()
243
+ print("Transaction committed")
244
+ except sqlite3.Error as e:
245
+ print(f"Error committing transaction: {e}")
246
+ pass
247
+
248
+ def rollback(self) -> None:
249
+ """
250
+ Rolls back the current transaction to undo changes.
251
+ """
252
+ try:
253
+ self.connection.rollback()
254
+ print("Transaction rolled back")
255
+ except sqlite3.Error as e:
256
+ pass
257
+ print(f"Error rolling back transaction: {e}")
258
+ def undo(self) -> None:
259
+ """
260
+ Rolls back the current transaction to undo changes.
261
+ """
262
+ try:
263
+ self.connection.rollback()
264
+ print("Transaction rolled back")
265
+ except sqlite3.Error as e:
266
+ pass
267
+ print(f"Error rolling back transaction: {e}")
268
+
269
+ def columns(self, table: str=None) -> List[str]:
270
+ """
271
+ Retrieve column names of a table.
272
+ usage: db.connect(db_path).columns('germany')
273
+ """
274
+ if table is None:
275
+ if isinstance(self.tables(),list):
276
+ table=self.tables()[0]
277
+ else:
278
+ table=self.tables()
279
+ query = f"PRAGMA table_info({table})"
280
+ rows = self.fetchall(query)
281
+ if rows:
282
+ return [row[1] for row in rows]
283
+ else:
284
+ return []
285
+
286
+ def vacuum(self) -> None:
287
+ """
288
+ Run the VACUUM command to rebuild the database file.
289
+ - Executes the VACUUM command to optimize the database file.
290
+ """
291
+ self.execute("VACUUM")
292
+ print("Database vacuumed")
293
+
294
+ def to_df(self, table: str=None, query: Optional[str] = None) -> pd.DataFrame:
295
+ if table is None:
296
+ if isinstance(self.tables(),list):
297
+ table=self.tables()[0]
298
+ else:
299
+ table=self.tables()
300
+ if query is None:
301
+ query = f"SELECT * FROM {table}"
302
+ try:
303
+ return pd.read_sql_query(query, self.connection)
304
+ except pd.DatabaseError as e:
305
+ print(f"Error converting query result to DataFrame: {e}")
306
+ return pd.DataFrame()
307
+ def to_sql(self, table:str=None, df = None, if_exists='fail',index=False,**kwargs):
308
+ """
309
+ to_sql
310
+ DataFrame.to_sql(name, con, *, schema=None, if_exists='fail',
311
+ index=True, index_label=None, chunksize=None, dtype=None, method=None)[source]
312
+ args:
313
+ if_exists: ‘fail’(default), ‘replace’, ‘append’
314
+ index: bool, default True
315
+ index_labelstr or sequence, default None
316
+
317
+ method{None, ‘multi’, callable}, optional Controls the SQL insertion clause used:
318
+ 'None': Uses standard SQL INSERT clause (one per row).
319
+ ‘multi’: Pass multiple values in a single INSERT clause.
320
+ 'callable': with signature (pd_table, conn, keys, data_iter).
321
+ """
322
+ if table is None:
323
+ if isinstance(self.tables(),list):
324
+ table=self.tables()[0]
325
+ else:
326
+ table=self.tables()
327
+ conn = self.connection
328
+ df.to_sql(table, conn, if_exists=if_exists, index=index, **kwargs)
329
+
330
+ # +++++++++ to add redo() function +++++++++
331
+ def log_change(self, operation: str, query: str, params: Optional[Tuple] = None):
332
+ """
333
+ Log the database operation to the change_log table.
334
+
335
+ Args:
336
+ - operation (str): The type of operation (e.g., 'INSERT', 'UPDATE', 'DELETE').
337
+ - query (str): The SQL query executed.
338
+ - params (tuple, optional): Parameters used in the query.
339
+ """
340
+ log_query = "INSERT INTO change_log (operation, query, params) VALUES (?, ?, ?)"
341
+ params_str = json.dumps(params) if params else None
342
+ self.execute(log_query, (operation, query, params_str))
343
+
344
+ def redo(self):
345
+ """
346
+ Reapply the changes from the change_log.
347
+ """
348
+ logs = self.fetchall("SELECT operation, query, params FROM change_log ORDER BY timestamp")
349
+ for log in logs:
350
+ operation, query, params_str = log
351
+ params = json.loads(params_str) if params_str else None
352
+ self.execute(query, params)
353
+ # +++++++++ to add redo() function +++++++++
354
+
355
+ if __name__ == "__main__":
356
+ pass