T
T
Tim2452020-11-27 22:59:28
Python
Tim245, 2020-11-27 22:59:28

How to insert parameters into SQL query?

How to insert the variables presented above instead of the words (James', 25, 'male', 'USA) here is the source code

jo = 'users228'
name = 'James'
age = '25'
male = 'male'
counre = 'USA'
cursor.execute("""
INSERT INTO
  {} (title, age, gender, nationality)
VALUES
  ('James', 25, 'male', 'USA');
""".format(jo))
conn.commit()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-11-27
@Tim245

Something like this:

cursor.execute("""INSERT INTO название_таблици (title, age, gender, nationality) VALUES(?,?,?,?)""",(name, age, male, counre, ))

There may be minor errors, because I did not check.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question