H
H
HelpMeeee2021-01-06 23:05:07
Python
HelpMeeee, 2021-01-06 23:05:07

Why does such a response come when working with sqlite3?

Greetings!
I study work of a python from a DB.
I write this code -

import sqlite3
import config

db = sqlite3.connect(config.database_name)
cursor = db.cursor()


"""

question = cursor.execute('SELECT qustion FROM qustions')
answer = cursor.execute('SELECT right_answer FROM qustions')"""

cursor.execute("""CREATE TABLE IF NOT EXISTS users(
   userid INT PRIMARY KEY,
   fname TEXT,
   lname TEXT,
   gender TEXT);
""")
db.commit()

cursor.execute("""INSERT INTO users(userid, fname, lname, gender) 
   VALUES('00001', 'Alex', 'Smith', 'male');""")
db.commit()

answer = cursor.execute('SELECT userid FROM users')
print(answer)

I get this answer -

I work in PyCharm, it starts to seem to me that it somehow interferes with normal work (does not support SQL or something else, although the site indicates that everything is OK)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wispik, 2021-01-06
@Wispik

Yes, I think it's really about pycharm, try to put something else... facepalm

if serious

cursor.fetchall()
cursor.fetchone()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question