Найти - Пользователи
Полная версия: sql request
Начало » Python для новичков » sql request
1
Genabox
подскажите пожалуйста как заполнит кортеж или sql запроса

 mycursor = myconnect.cursor(buffered=False)
mycursor.execute('SELECT name FROM name_table')
myresult = mycursor.fetchall()
for row in myresult: 
    #print(row)
{how to make it??}
py.user.next
Весь код приведи.

[code python] 
тут пиши код
[/code]
Genabox
 from_db = []
mycursor = myconnect.cursor(buffered=False)
mycursor.execute('SELECT name FROM name_table)
myresult = mycursor.fetchall()
for row in myresult:
    myresult = list(myresult)
    from_db.append(row[0])
    uniqueNames=set(from_db)
    
print(uniqueNames)
а вот разобрался
py.user.next
  
mycursor = myconnect.cursor(buffered=False)
mycursor.execute('SELECT name FROM name_table')
myresult = mycursor.fetchall()
 
from_db = []
for row in myresult:
    name = row[0]
    from_db.append(name)
 
uniq_names = list(set(from_db))
 
print(from_db)
print(uniq_names)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB