aboutsummaryrefslogtreecommitdiff
path: root/trygvis/eda/cli/db_stats.py
diff options
context:
space:
mode:
Diffstat (limited to 'trygvis/eda/cli/db_stats.py')
-rwxr-xr-xtrygvis/eda/cli/db_stats.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/trygvis/eda/cli/db_stats.py b/trygvis/eda/cli/db_stats.py
new file mode 100755
index 0000000..4780c20
--- /dev/null
+++ b/trygvis/eda/cli/db_stats.py
@@ -0,0 +1,39 @@
+from trygvis.eda import cli
+
+
+def run(db_path):
+ g = cli.open_database(db_path)
+
+ res = cli.sparql(g, """
+SELECT ?schematic ?label
+WHERE {
+ ?schematic a kicad-type:schematic
+ OPTIONAL {
+ ?schematic rdfs:label ?label
+ }
+}
+""")
+ cli.info("Found %d schematics in database" % len(res))
+ for row in res:
+ name = row.label if row.label is not None else "<unnamed>"
+ url = row.schematic
+
+ cli.info("%s:" % name)
+ cli.info(" URL: %s" % url)
+ cli.info()
+
+ res = cli.sparql(g, """
+SELECT
+ ?dk_part ?dk_part_number ?label
+WHERE {
+ ?dk_part a dk:part ;
+ dk:partNumber ?dk_part_number .
+ OPTIONAL {
+ ?dk_part rdfs:label ?label
+ }
+}
+ORDER BY ?dk_part_number
+ """)
+ cli.info("Found %d Digi-Key parts:" % len(res))
+ for row in res:
+ cli.info(" %-30s: %s" % (row.dk_part_number, row.label))