Skip to content

Commit daea436

Browse files
Léonard Micheletleonarf
authored andcommitted
search with siren works now
1 parent b214774 commit daea436

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

enthic/app.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,16 @@ def company_denomination_year(sirens):
9191
:return: HTTP Response as application/json. Contain all existing siren.
9292
"""
9393
sirenlist = sirens.split(",")
94-
sql_query = (
95-
"SELECT siren FROM `identity` WHERE siren IN " + str(tuple(sirenlist)) + "; "
96-
)
94+
if len(sirenlist) > 1:
95+
sql_query = (
96+
"SELECT siren FROM `identity` WHERE siren IN "
97+
+ str(tuple(sirenlist))
98+
+ "; "
99+
)
100+
elif len(sirenlist) == 1:
101+
sql_query = (
102+
"SELECT siren FROM `identity` WHERE siren = " + str(sirenlist[0]) + "; "
103+
)
97104
existing_siren = fetchall(sql_query)
98105
result = [item[0] for item in existing_siren]
99106
return OKJSONResponse(result)

0 commit comments

Comments
 (0)