0

I know how to store data into a database if I know the value of what I am storing. For example:

sql="INSERT INTO nameDatabase (name) Values('Joe')"

However, I want to be able to store data that I do not know the value of into my database. So I can prompt the user for the name of something and then store that into my database.

I tried to put the variable into Values but I received an error.

name='John'
sql="INSERT INTO nameDatabase (name) Values(name)"

error was "no such column: name"

So how can I do this?

1
Contributor
1
Reply
2
Views
8 Years
Discussion Span
Last Post by jcmeyer
0

I figured it out.

Name='John'
self.cursor.execute('INSERT INTO nameDatabase VALUES (null,?)',[Name])
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.