SQL query str alchemy Query

In fact, I have code that extracts the necessary data from a text file.

Here I am extracting some id from a text file.

Then I need to pass the same to the SQLAlchemy query to get the results.

But I do not get the results as needed here.

here is the code:

addys = ','.join('"{}"'.format(''.join(tenant)) for tenant in tenants if tenant)
#print "%s" % (addys)

# cleanup and close files
files.close()

query1 = query1.filter(model.name == "in-addr.arpa.")
query2 = query2.filter(model.tenant_id.in_([addys]))

Here the addys type is as follows:

<type 'str'>

I do not get the result here as needed.

Someone helps me with the same.

Note:

When printing addys receiving results as shown below:

"1235b3a73ad24b9c86cf301525310b24","cbdf25542c194a069464f69efff4859a"
+4
source share
2 answers

_in , - id, . :

query = query.filter(model.tenant_id.in_(addys.split(',')))

:

tenant_ids = [''.join(tenant) for tenant in tenants if tenant]
query = query.filter(model.tenant_id.in_(tenant_ids))
+3

, :

addys = [tenant for tenant in tenants if tenant]

query2 = query2.filter(model.tenant_id.in_(addys))
0

Source: https://habr.com/ru/post/1613822/


All Articles