Click here to Skip to main content
15,886,587 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello, lets say i have a table that contains id , name, user-name.
suppose i have a list of name : name=['A','B','C',...]. using python
how to read all data id name user-name but only if name is in the list.
second question if i have the row around 20000000 rows. it take long time to search and get what i need? and what is the best way to reduce time ?
thanks in advance.

What I have tried:

i searched for 'any' but no results.
Posted
Comments
CHill60 13-Mar-17 10:20am    
Share the code you are using and try to explain your problem more clearly
Member 11436383 13-Mar-17 11:06am    
i have a table user: id, name, user-name. its around 20000000 rows.
i have a list of name which i need to select all data name id and user-name but only if name in the list. the list length i about 6000. this is the code but one by one it take long time to complete!!.

data = []
for i in range(0,len(name_list)):
cur.execute(
'SELECT user.name, id, user-name,FROM user WHERE name = %s,
(name_list)
)

m = cur.fetchall()
data.append(m)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900