Answer the question
In order to leave comments, you need to log in
How to extract a variable from a SQLite database?
How can I pull in a variable from a SQLite database?
Code example:
import sqlite3 as sql
conn = sql.connect('database.db')
cur = conn.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS test(test_int INT)""")
conn.commit()
print(test_int) #Нужно вывести переменную test_int из базы данных
Answer the question
In order to leave comments, you need to log in
import sqlite3
db = sqlite3.connect('database.db')
cur = db.cursor()
a = str(cur.execute('SELECT column_name FROM table_name WHERE id = row_id').fetchone()[0])
print( a)
test_int INT is not a variable here, but the name of a column in the test table, where records of the int type are stored. So far it hasn't written anything.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question