Уведомления

Группа в Telegram: @pythonsu

#1 Март 30, 2021 21:46:08

Anton13
Зарегистрирован: 2021-03-27
Сообщения: 11
Репутация: +  0  -
Профиль   Отправить e-mail  

Как вставить названия таблиц динамически?

Привет всем, пробую так:
не хочет!
import sqlite3

connection = sqlite3.connect("D:\\test\\test.db")
cursor = connection.cursor()

name = 'Anton'
surname = 'Ivanov'
age = 32


cursor.execute('CREATE TABLE IF NOT EXISTS people (first_name text, last_name text, age real)')
cursor.execute(f"INSERT INTO people VALUES ({name}, {surname}, {age})")
connection.commit()
cursor.execute('select * from people')
result = cursor.fetchall()
print(result)
cursor.close()
connection.close()

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version