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?

I figured it out.

Name='John'
self.cursor.execute('INSERT INTO nameDatabase VALUES (null,?)',[Name])
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.