12 ответов
+ 7
i guess first thing is to insert a name o_O
check = c.execute('INSERT into Table_name VALUES (?)', 'John')
+ 7
and then:
name="John"
check = c.execute("SELECT name from Table_name WHERE name="+name)
+ 7
might be for the best
SQL ain't my strong suite xD
+ 6
have you checked the API?
https://docs.python.org/3/library/sqlite3.html
+ 6
can you post any code you have so far?
+ 6
and do you have anything in the table?
sorry my SQL is rusty xD
http://sebastianraschka.com/Articles/2014_sqlite_in_python_tutorial.html
some nice info here
+ 6
according to the link i posted:
"if we use the .fetchall() method, we return a list of tuples from the database query, where each tuple represents one row entry. "
so it shouldn't be an issue that it displays [(0,)] instead of 0
+ 1
So, how to pair it with Python? How to check if name is in table?
0
Yes, checked. But can't find the right function
0
c = conn.cursor()
name = 'John'
check = c.execute('SELECT count(name) FROM table_name')
c.fetchall()
>>> ([0,])
I need at least 0 instead of ([0,])
0
No, didn't help. Still the output is [(0,)] instead of 0
0
I'll check this site