Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spyder IDE editor multiline string query (Python 3.6)

I'm trying to make a SQL query that can be used with pandas.read_sql_query.

query = '''SELECT var1, var2, var3, var4,
        var5, var6, var7, var8, var9
        FROM table 
        WHERE area='there' '''

This works when running in the console, but when I try to execute this in the Spyder editor I see the following:

SyntaxError: EOF while scanning triple-quoted string literal

like image 417
user3342735 Avatar asked Feb 27 '26 17:02

user3342735


1 Answers

(Spyder maintainer here) The problem is your trying to run your selected code line by line with our Run selection or current line functionality. After running the first line in your code, i.e.

query = '''SELECT var1, var2, var3, var4,

it's clear you'll get

SyntaxError: EOF while scanning triple-quoted string literal

because that line doesn't close the string you started.

Note: Run selection or current line expects a complete Python statement, i.e. something that can be evaluated as it is in Python (e.g. a = 10).

like image 158
Carlos Cordoba Avatar answered Mar 02 '26 06:03

Carlos Cordoba