dbgraph 0.2.4__tar.gz → 0.2.6__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 (86) hide show
  1. {dbgraph-0.2.4 → dbgraph-0.2.6}/.idea/workspace.xml +11 -10
  2. {dbgraph-0.2.4 → dbgraph-0.2.6}/PKG-INFO +1 -1
  3. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/persistent/models.py +6 -0
  4. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/persistent/sql_graph_persistent.py +10 -1
  5. {dbgraph-0.2.4 → dbgraph-0.2.6}/pyproject.toml +1 -1
  6. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/test_sql_graph_persistent.py +9 -0
  7. {dbgraph-0.2.4 → dbgraph-0.2.6}/uv.lock +1 -1
  8. {dbgraph-0.2.4 → dbgraph-0.2.6}/.gitignore +0 -0
  9. {dbgraph-0.2.4 → dbgraph-0.2.6}/.idea/.gitignore +0 -0
  10. {dbgraph-0.2.4 → dbgraph-0.2.6}/.idea/dbgraph.iml +0 -0
  11. {dbgraph-0.2.4 → dbgraph-0.2.6}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
  12. {dbgraph-0.2.4 → dbgraph-0.2.6}/.idea/misc.xml +0 -0
  13. {dbgraph-0.2.4 → dbgraph-0.2.6}/.idea/modules.xml +0 -0
  14. {dbgraph-0.2.4 → dbgraph-0.2.6}/.idea/vcs.xml +0 -0
  15. {dbgraph-0.2.4 → dbgraph-0.2.6}/.python-version +0 -0
  16. {dbgraph-0.2.4 → dbgraph-0.2.6}/README.md +0 -0
  17. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-desc.md +0 -0
  18. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-graph-import.db +0 -0
  19. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-graph-v2.json +0 -0
  20. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-graph-v4.json +0 -0
  21. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-graph.db +0 -0
  22. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-graph.json +0 -0
  23. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-graph.png +0 -0
  24. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-index/corpus.jsonl +0 -0
  25. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-index/corpus.mmindex.json +0 -0
  26. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-index/data.csc.index.npy +0 -0
  27. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-index/indices.csc.index.npy +0 -0
  28. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-index/indptr.csc.index.npy +0 -0
  29. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-index/params.index.json +0 -0
  30. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-index/vocab.index.json +0 -0
  31. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind-semantic-v5.json +0 -0
  32. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/northwind.db +0 -0
  33. {dbgraph-0.2.4 → dbgraph-0.2.6}/data/time-results.txt +0 -0
  34. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/__init__.py +0 -0
  35. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/application.py +0 -0
  36. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/builder/__init__.py +0 -0
  37. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/builder/graph_builder.py +0 -0
  38. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/builder/sql_graph_builder.py +0 -0
  39. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/descriptor/__init__.py +0 -0
  40. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/descriptor/graph_descriptor.py +0 -0
  41. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/descriptor/langchain_graph_descriptor.py +0 -0
  42. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/descriptor/prompt_templates.py +0 -0
  43. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/entity/__init__.py +0 -0
  44. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/entity/aspect.py +0 -0
  45. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/entity/asset.py +0 -0
  46. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/entity/asset_type.py +0 -0
  47. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/entity/dbgraph.py +0 -0
  48. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/entity/link.py +0 -0
  49. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/entity/link_type.py +0 -0
  50. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/entity/rdbgraph.py +0 -0
  51. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/io/__init__.py +0 -0
  52. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/io/graph_loader.py +0 -0
  53. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/io/graph_writer.py +0 -0
  54. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/io/json_graph_loader.py +0 -0
  55. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/io/json_graph_writer.py +0 -0
  56. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/persistent/__init__.py +0 -0
  57. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/persistent/graph_persistent.py +0 -0
  58. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/persistent/json_utils.py +0 -0
  59. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/render/__init__.py +0 -0
  60. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/render/graph_renderer.py +0 -0
  61. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/render/markdown_renderer.py +0 -0
  62. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/search/__init__.py +0 -0
  63. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/search/bm25_search_engine.py +0 -0
  64. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/search/search_engine.py +0 -0
  65. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/utils/__init__.py +0 -0
  66. {dbgraph-0.2.4 → dbgraph-0.2.6}/dbgraph/utils/singleton.py +0 -0
  67. {dbgraph-0.2.4 → dbgraph-0.2.6}/diagrams/entity.png +0 -0
  68. {dbgraph-0.2.4 → dbgraph-0.2.6}/diagrams/entity.txt +0 -0
  69. {dbgraph-0.2.4 → dbgraph-0.2.6}/diagrams/usecase.png +0 -0
  70. {dbgraph-0.2.4 → dbgraph-0.2.6}/diagrams/usecase.txt +0 -0
  71. {dbgraph-0.2.4 → dbgraph-0.2.6}/docs/index.md +0 -0
  72. {dbgraph-0.2.4 → dbgraph-0.2.6}/docs/refs/aspect.md +0 -0
  73. {dbgraph-0.2.4 → dbgraph-0.2.6}/docs/refs/graph.md +0 -0
  74. {dbgraph-0.2.4 → dbgraph-0.2.6}/main.py +0 -0
  75. {dbgraph-0.2.4 → dbgraph-0.2.6}/mkdocs.yml +0 -0
  76. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/__init__.py +0 -0
  77. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/test_application.py +0 -0
  78. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/test_bm25s_search_engine.py +0 -0
  79. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/test_dbgraph.py +0 -0
  80. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/test_json_graph_loader.py +0 -0
  81. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/test_json_graph_writer.py +0 -0
  82. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/test_langchain_graph_descriptor.py +0 -0
  83. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/test_load_graph_sql.py +0 -0
  84. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/test_markdown_renderer.py +0 -0
  85. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/test_rdbgraph.py +0 -0
  86. {dbgraph-0.2.4 → dbgraph-0.2.6}/tests/test_sql_graph_builder.py +0 -0
@@ -10,6 +10,11 @@
10
10
  <change beforePath="$PROJECT_DIR$/data/northwind-index/indices.csc.index.npy" beforeDir="false" afterPath="$PROJECT_DIR$/data/northwind-index/indices.csc.index.npy" afterDir="false" />
11
11
  <change beforePath="$PROJECT_DIR$/data/northwind-index/indptr.csc.index.npy" beforeDir="false" afterPath="$PROJECT_DIR$/data/northwind-index/indptr.csc.index.npy" afterDir="false" />
12
12
  <change beforePath="$PROJECT_DIR$/data/northwind-index/vocab.index.json" beforeDir="false" afterPath="$PROJECT_DIR$/data/northwind-index/vocab.index.json" afterDir="false" />
13
+ <change beforePath="$PROJECT_DIR$/dbgraph/persistent/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/dbgraph/persistent/models.py" afterDir="false" />
14
+ <change beforePath="$PROJECT_DIR$/dbgraph/persistent/sql_graph_persistent.py" beforeDir="false" afterPath="$PROJECT_DIR$/dbgraph/persistent/sql_graph_persistent.py" afterDir="false" />
15
+ <change beforePath="$PROJECT_DIR$/pyproject.toml" beforeDir="false" afterPath="$PROJECT_DIR$/pyproject.toml" afterDir="false" />
16
+ <change beforePath="$PROJECT_DIR$/tests/test_sql_graph_persistent.py" beforeDir="false" afterPath="$PROJECT_DIR$/tests/test_sql_graph_persistent.py" afterDir="false" />
17
+ <change beforePath="$PROJECT_DIR$/uv.lock" beforeDir="false" afterPath="$PROJECT_DIR$/uv.lock" afterDir="false" />
13
18
  </list>
14
19
  <option name="SHOW_DIALOG" value="false" />
15
20
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -77,6 +82,7 @@
77
82
  &quot;Python tests.Python tests for tests.test_sql_graph_builder.TestSQLGraphBuilder.test__build_links.executor&quot;: &quot;Run&quot;,
78
83
  &quot;Python tests.Python tests for tests.test_sql_graph_builder.TestSQLGraphBuilder.test_build_graph.executor&quot;: &quot;Run&quot;,
79
84
  &quot;Python tests.Python tests for tests.test_sql_graph_persistent.TestSQLGraphPersistent.executor&quot;: &quot;Run&quot;,
85
+ &quot;Python tests.Python tests for tests.test_sql_graph_persistent.TestSQLGraphPersistent.test_delete_graph.executor&quot;: &quot;Run&quot;,
80
86
  &quot;Python tests.Python tests for tests.test_sql_graph_persistent.TestSQLGraphPersistent.test_load_graph.executor&quot;: &quot;Run&quot;,
81
87
  &quot;Python tests.Python tests for tests.test_sql_graph_persistent.TestSQLGraphPersistent.test_save_graph.executor&quot;: &quot;Run&quot;,
82
88
  &quot;Python tests.Python tests in test_load_graph_sql.py.executor&quot;: &quot;Run&quot;,
@@ -91,7 +97,7 @@
91
97
  &quot;settings.editor.selected.configurable&quot;: &quot;editor.preferences.folding&quot;
92
98
  }
93
99
  }</component>
94
- <component name="RunManager" selected="Python tests.Python tests for tests.test_json_graph_loader.TestJSONGraphLoader.test_get_neighbors_sub_graph">
100
+ <component name="RunManager" selected="Python tests.Python tests for tests.test_sql_graph_persistent.TestSQLGraphPersistent.test_delete_graph">
95
101
  <configuration name="Python tests for tests.test_json_graph_loader.TestJSONGraphLoader.test_get_neighbors_sub_graph" type="tests" factoryName="Autodetect" temporary="true" nameIsGenerated="true">
96
102
  <module name="dbgraph" />
97
103
  <option name="ENV_FILES" value="" />
@@ -143,7 +149,7 @@
143
149
  <option name="_new_targetType" value="&quot;PYTHON&quot;" />
144
150
  <method v="2" />
145
151
  </configuration>
146
- <configuration name="Python tests for tests.test_sql_graph_builder.TestSQLGraphBuilder.test_build_graph" type="tests" factoryName="Autodetect" temporary="true" nameIsGenerated="true">
152
+ <configuration name="Python tests for tests.test_sql_graph_persistent.TestSQLGraphPersistent.test_delete_graph" type="tests" factoryName="Autodetect" temporary="true" nameIsGenerated="true">
147
153
  <module name="dbgraph" />
148
154
  <option name="ENV_FILES" value="" />
149
155
  <option name="INTERPRETER_OPTIONS" value="" />
@@ -156,7 +162,7 @@
156
162
  <option name="DEBUG_JUST_MY_CODE" value="false" />
157
163
  <option name="RUN_TOOL" value="" />
158
164
  <option name="_new_additionalArguments" value="&quot;&quot;" />
159
- <option name="_new_target" value="&quot;tests.test_sql_graph_builder.TestSQLGraphBuilder.test_build_graph&quot;" />
165
+ <option name="_new_target" value="&quot;tests.test_sql_graph_persistent.TestSQLGraphPersistent.test_delete_graph&quot;" />
160
166
  <option name="_new_targetType" value="&quot;PYTHON&quot;" />
161
167
  <method v="2" />
162
168
  </configuration>
@@ -179,11 +185,11 @@
179
185
  </configuration>
180
186
  <recent_temporary>
181
187
  <list>
188
+ <item itemvalue="Python tests.Python tests for tests.test_sql_graph_persistent.TestSQLGraphPersistent.test_delete_graph" />
182
189
  <item itemvalue="Python tests.Python tests for tests.test_json_graph_loader.TestJSONGraphLoader.test_get_neighbors_sub_graph" />
183
190
  <item itemvalue="Python tests.Python tests in tests" />
184
191
  <item itemvalue="Python tests.Python tests for tests.test_sql_graph_builder.TestSQLGraphBuilder" />
185
192
  <item itemvalue="Python tests.Python tests for tests.test_sql_graph_builder.TestSQLGraphBuilder.test__build_links" />
186
- <item itemvalue="Python tests.Python tests for tests.test_sql_graph_builder.TestSQLGraphBuilder.test_build_graph" />
187
193
  </list>
188
194
  </recent_temporary>
189
195
  </component>
@@ -312,12 +318,7 @@
312
318
  <breakpoints>
313
319
  <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
314
320
  <url>file://$PROJECT_DIR$/dbgraph/persistent/sql_graph_persistent.py</url>
315
- <line>330</line>
316
- <option name="timeStamp" value="4" />
317
- </line-breakpoint>
318
- <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
319
- <url>file://$PROJECT_DIR$/dbgraph/persistent/sql_graph_persistent.py</url>
320
- <line>351</line>
321
+ <line>360</line>
321
322
  <option name="timeStamp" value="5" />
322
323
  </line-breakpoint>
323
324
  </breakpoints>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: dbgraph
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: dbgraph is a database profiling tool which model the database as a graph
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: bm25s>=0.3.9
@@ -66,6 +66,7 @@ class AssetModel(Base):
66
66
  ForeignKey(
67
67
  "graphs.graph_id",
68
68
  ondelete="CASCADE",
69
+ onupdate="CASCADE"
69
70
  ),
70
71
  nullable=False,
71
72
  index=True,
@@ -116,6 +117,7 @@ class LinkModel(Base):
116
117
  ForeignKey(
117
118
  "assets.asset_id",
118
119
  ondelete="CASCADE",
120
+ onupdate="CASCADE"
119
121
  ),
120
122
  nullable=False,
121
123
  index=True,
@@ -125,6 +127,7 @@ class LinkModel(Base):
125
127
  ForeignKey(
126
128
  "assets.asset_id",
127
129
  ondelete="CASCADE",
130
+ onupdate="CASCADE"
128
131
  ),
129
132
  nullable=False,
130
133
  index=True,
@@ -134,6 +137,7 @@ class LinkModel(Base):
134
137
  ForeignKey(
135
138
  "graphs.graph_id",
136
139
  ondelete="CASCADE",
140
+ onupdate="CASCADE"
137
141
  ),
138
142
  nullable=False,
139
143
  index=True,
@@ -167,6 +171,7 @@ class AssetAspectModel(Base):
167
171
  ForeignKey(
168
172
  "assets.asset_id",
169
173
  ondelete="CASCADE",
174
+ onupdate="CASCADE"
170
175
  ),
171
176
  primary_key=True,
172
177
  )
@@ -198,6 +203,7 @@ class LinkAspectModel(Base):
198
203
  ForeignKey(
199
204
  "links.link_id",
200
205
  ondelete="CASCADE",
206
+ onupdate="CASCADE"
201
207
  ),
202
208
  primary_key=True,
203
209
  )
@@ -1,7 +1,7 @@
1
1
  import json
2
2
  from dataclasses import asdict, dataclass
3
3
 
4
- from sqlalchemy import create_engine, delete, select, update
4
+ from sqlalchemy import create_engine, delete, select, update, event
5
5
  from sqlalchemy.orm import Session
6
6
 
7
7
  from dbgraph.entity.aspect import (
@@ -41,8 +41,17 @@ class SQLGraphPersistent(GraphPersistent):
41
41
 
42
42
  def __post_init__(self):
43
43
  self.engine = create_engine(self.db_uri)
44
+
45
+ @event.listens_for(self.engine, "connect")
46
+ def set_sqlite_pragma(dbapi_connection, connection_record):
47
+ if dbapi_connection.__class__.__module__.startswith("sqlite3"):
48
+ cursor = dbapi_connection.cursor()
49
+ cursor.execute("PRAGMA foreign_keys=ON")
50
+ cursor.close()
51
+
44
52
  Base.metadata.create_all(bind=self.engine)
45
53
 
54
+
46
55
  def create_graph(self, graph_id: str, graph_name: str):
47
56
  graph_model = GraphModel(graph_id=graph_id, name=graph_name, completed=False)
48
57
  with Session(self.engine) as session:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "dbgraph"
7
- version = "0.2.4"
7
+ version = "0.2.6"
8
8
  description = "dbgraph is a database profiling tool which model the database as a graph"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -441,6 +441,15 @@ class TestSQLGraphPersistent(unittest.TestCase):
441
441
  graph = self.persistent.load_graph(self.graph_id)
442
442
  self.assertEqual(self.graph, graph)
443
443
 
444
+ def test_delete_graph(self):
445
+ self.persistent.save_graph(self.graph, self.graph_id)
446
+ graph = self.persistent.load_graph(self.graph_id)
447
+ self.assertEqual(self.graph, graph)
448
+ self.persistent.delete_graph(self.graph_id)
449
+ graph = self.persistent.load_graph(self.graph_id)
450
+ self.assertEqual(0, len(graph.assets))
451
+ self.assertEqual(0, len(graph.links))
452
+
444
453
  def test_get_graph_info(self):
445
454
  graph_info = self.persistent.get_graph_info("1")
446
455
  self.assertEqual(graph_info[1], "graph-1")
@@ -284,7 +284,7 @@ wheels = [
284
284
 
285
285
  [[package]]
286
286
  name = "dbgraph"
287
- version = "0.2.2"
287
+ version = "0.2.5"
288
288
  source = { editable = "." }
289
289
  dependencies = [
290
290
  { name = "bm25s" },
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
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
File without changes
File without changes
File without changes