Skip to content

Commit

Permalink
added some functionality to get the expanded information of the table…
Browse files Browse the repository at this point in the history
…s, mostly worked in server.py to interact with init.sql
  • Loading branch information
CoraBailey committed Nov 15, 2023
1 parent 2e9190f commit b1c1bcb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def get_all_entries():
"""
with Database() as db:
try:
entries_sql = db.execute_return("""SELECT id, name FROM proteins""")
entries_sql = db.execute_return("""SELECT id, name, filePDBAlphaFold, length, mass FROM proteins""")
log.warn(entries_sql)

# if we got a result back
if entries_sql is not None:
return [
ProteinEntry(id=str(entry[0]), name=entry[1])
ProteinEntry(id=str(entry[0]), name=entry[1], filePDBAlphaFold=entry[2], length=entry[3], mass=entry[4])
for entry in entries_sql
]
except Exception as e:
Expand All @@ -37,7 +37,7 @@ def get_protein_entry(protein_id: str):
with Database() as db:
try:
entry_sql = db.execute_return(
"""SELECT id, name FROM proteins
"""SELECT id, name, filePDBAlphaFold, length, mass FROM proteins
WHERE id = %s""",
[protein_id],
)
Expand All @@ -46,7 +46,7 @@ def get_protein_entry(protein_id: str):
# if we got a result back
if entry_sql is not None and len(entry_sql) != 0:
# return the only entry
return ProteinEntry(id=str(entry_sql[0][0]), name=entry_sql[0][1])
return ProteinEntry(id=str(entry_sql[0][0]), name=entry_sql[0][1], filePDBAlphaFold=entry_sql[0][2], length=entry_sql[0][3], mass=entry_sql[0][4])

except Exception as e:
log.error(e)
Expand Down

0 comments on commit b1c1bcb

Please sign in to comment.