I was trying to figure out how to work with SQLite database using python, but seem to be stuck. I think I am missing something basic. I was following this tutorial: http://docs.python.org/library/sqlite3.html
私は以下の情報を含むようにデータベースをセットアップしました:
import sqlite3
conn = sqlite3.connect('SQL_test_3') #this creates a seperate file
c = conn.cursor()
c.execute('''create table stocks
(date text, trans text, symbol text,
qty real, price real)''')
data = [('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
('2006-04-05', 'BUY', 'MSFT', 1000, 72.00),
('2006-04-06', 'SELL', 'IBM', 500, 53.00),
]
for t in data:
c.execute('insert into stocks values (?,?,?,?,?)', t)
conn.commit()
c.close()
データを抽出しようとすると、私の問題が発生します。このチュートリアルでは、特性の1つが満たされている場合にデータを抽出する方法について説明します。
(別のファイルでデータベースを開くと)
import sqlite3
conn = sqlite3.connect('SQL_test_3')
c = conn.cursor()
price = 53
t = (price,)
c.execute('select * from stocks where price=?', t)
print c.fetchall()
The above works perfect, but what if I want extract information for all the assets who's price is greater that 50, I can't do it. Doing price > 50 and price>? doesn't work...
だから私の質問は:
1) How do I extract information for an asset when the key criteria is fits in a given range, for example price > 50 or 40 < price < 70.
2)IBMの株式に関する情報などの2つの基準を設定する場合、
もしその株式が、例えば50以上の価格で取引されていれば。
私は自分の質問が非常に初心者/基本的だと思っていますが、私はチュートリアルで回答を見つけることができませんでした。
どんな助けもありがとうございます。
前もって感謝します。