Hi everyone,

I'm trying to write a Python script, where it counts the specific results from a database.

Running the following line in MySQL Client works:
SELECT name, COUNT(*) FROM results WHERE name="bla bla";

And it returns all of the results fine.

But I'm trying to put it into a Python script and I keep getting a 'Check your syntax' message:

cursor.execute("SELECT name, COUNT(*) FROM results WHERE name="bla bla"");

Any ideas?

You have to escape the quotation marks.

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.