Тема: SQLite - записати змінні у базу данних
Я працюю з SQLite3 через BD browser але не зміг записати змінні у базу данних. Допоможіть будь ласка, буду дуже вдячний:)
Код:
import sqlite3
connection = sqlite3.connect('resume.sl3', 5)
cursor = connection.cursor()
cursor.execute('CREATE TABLE resume_table (Questions TEXT, Answers TEXT);')
print('Welcome to resume placeholder!')
def resume():
print('OK')
name = input('What`s your name?: ')
birthday = input('What`s your date of birth: ')
work_experience = input('What was your work experience?: ')
phone_number = input('What is your phone number?: ')
address = input('What is your address?: ')
print(f'Name - {name}'
f'\nBirthday - {birthday}'
f'\nWork experience - {work_experience}'
f'\nPhone number - {phone_number}'
f'\nAddress - {address}')
resume_text()
def resume_text():
connection.execute(f"INSERT INTO resume_table (Questions, Answers) VALUES 'Name', {name};")
connection.execute(f"INSERT INTO resume_table (Questions, Answers) VALUES 'Birthday', {birthday};")
connection.execute(f"INSERT INTO resume_table (Questions, Answers) VALUES 'Work experience', {work_experience};")
connection.execute(f"INSERT INTO resume_table (Questions, Answers) VALUES 'Phone number', {phone_number};")
connection.execute(f"INSERT INTO resume_table (Questions, Answers) VALUES 'Address', {address};")
connection.commit()
connection.close()
try:
first_y_or_n = input('Want to start?: ')
if first_y_or_n == 'y':
resume()
elif first_y_or_n == 'n':
print('Exit...')
except Exception as exc:
print(f'Error {exc}')