2016-06-08 52 views
-2

在我的python腳本中使用SQLalchemy引擎API時,我想從表中選擇幾列,並在其他列上使用where子句。我的查詢如下所示。我已成功連接引擎。我知道我做了一些小的失誤,請大家幫忙在我的Python腳本中使用SQLALCHEMY

connection = engine.connect() 
data=connection.execute("SELECT ID FROM Table1 WHERE Column1 =='India') 
connection.close() 
+1

我不認爲你需要雙等號查詢 –

+1

在發佈代碼時有失蹤「。 – ib11

回答

0

試試這個:

from sqlalchemy.sql import text 
connection = engine.connect() 
s = text("select * 
    FROM Table1 
    WHERE Table1.Country = 'India'") 
data=connection.execute(s)