2017-01-15 14 views
0

これは動作しません:私は要素を取得しません。Pythonのsqlite3コネクタ

K0は、DKはintで、フロートnumpyのである:

(k0, dk) 
(<class 'numpy.float64'>, <class 'int'>) 
(20.083143869749225, 6) 

-

get_close_rods = "select xmid, ymid, angle from datos where experiment_id=? " 
get_close_rods+= "and file_id=? and ymid between ? and ? and xmid between ? and ? and angle between ? and ? " 
get_close_rods+= "and major/minor between ? and ? order by ((xmid-?)*(xmid-?)+(ymid-?)*(ymid-?))*angle" 
#get_close_rods+= "order by ((xmid-?)*(xmid-?)+(ymid-?)*(ymid-?))*angle" 

args = (str(experiment_id_), str(file_ids[index+1]), str(pos0[1]-dd), 
      str(pos0[1]+dd), str(pos0[0]-dd), str(pos0[0]+dd), 
      str(angle-dangle), str(angle+dangle), str(k0-dk), str(k0+dk), 
      str(pos0[0]), str(pos0[0]), str(pos0[1]), str(pos0[1])) 

cursor2.execute(get_close_rods, args) 

STR(K0-DK)、STR(K0 + DK)

それはdoesnの次のいずれかを行います。

get_close_rods = "select xmid, ymid, angle, from datos where experiment_id=? " 
get_close_rods+= "and file_id=? and ymid between ? and ? and xmid between ? and ? and angle between ? and ? " 
get_close_rods+= "and major/minor between ? and ? order by ((xmid-?)*(xmid-?)+(ymid-?)*(ymid-?))*angle" 
#get_close_rods+= "order by ((xmid-?)*(xmid-?)+(ymid-?)*(ymid-?))*angle" 

args = (str(experiment_id_), str(file_ids[index+1]), str(pos0[1]-dd), 
      str(pos0[1]+dd), str(pos0[0]-dd), str(pos0[0]+dd), 
      str(angle-dangle), str(angle+dangle), str(15), str(25), 
      str(pos0[0]), str(pos0[0]), str(pos0[1]), str(pos0[1])) 

cursor2.execute(get_close_rods, args) 

STR(15)私はSTR(フロート(15))、STR(フロート(25))を置けば、STR(25)

はどちらか動作しません。

このクエリを使用すると、エラーは表示されません。

しかし、これは動作します。

get_close_rods = "select xmid, ymid, angle, from datos where experiment_id=? " 
get_close_rods+= "and file_id=? and ymid between ? and ? and xmid between ? and ? and angle between ? and ? " 
#get_close_rods+= "and major/minor between ? and ? order by ((xmid-?)*(xmid-?)+(ymid-?)*(ymid-?))*angle" 
#get_close_rods+= "order by ((xmid-?)*(xmid-?)+(ymid-?)*(ymid-?))*angle" 
get_close_rods+= "and major/minor between 15 and 25 order by ((xmid-?)*(xmid-?)+(ymid-?)*(ymid-?))*angle" 

args = (str(experiment_id_), str(file_ids[index+1]), str(pos0[1]-dd), 
      str(pos0[1]+dd), str(pos0[0]-dd), str(pos0[0]+dd), 
      str(angle-dangle), str(angle+dangle), #str(15), str(25), 
      str(pos0[0]), str(pos0[0]), str(pos0[1]), str(pos0[1])) 

cursor2.execute(get_close_rods, args) 

#str(15)、値を直接使用したSTR(25)

+0

と* args取得する:Typ eError:関数は最大2つの引数をとります(与えられた15個) –

+0

nope:14個の疑問符、14個の引数 –

答えて

0

がそれを修正:

args = (..., 15, 25, ...) 

または:

args = (..., k0-dk, k0+dk, ...)