MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / search

Function search

projects/CRUD-with-postgresql/main.py:183–198  ·  view source on GitHub ↗
(key, value)

Source from the content-addressed store, hash-verified

181 # You can search by name, url, author, hash
182 # This makes it easy to search for a entry
183 def search(key, value):
184 cursor.execute(f"SELECT * from dbview WHERE {key}='{value}'")
185 records = cursor.fetchall()
186 table = Table(
187 title=Panel(f'Query DB [red]{info["host"]}:{info["port"]}'),
188 show_header=True,
189 header_style="bold green",
190 )
191 table.add_column("Name", style="purple", width=20)
192 table.add_column("Url", style="yellow")
193 table.add_column("Channel", style="cyan")
194 table.add_column("Hash", style="dim")
195 table.add_column("Date", no_wrap=True, style="dim blue")
196 for record in records:
197 table.add_row(record[0], record[1], record[2], record[3], str(record[4]))
198 console.print(table)
199
200 loop = 1
201 # 12 is a rather arbitrary number

Callers 1

insertFunction · 0.85

Calls 1

executeMethod · 0.45

Tested by

no test coverage detected