ãã¼ã¿ãã¼ã¹ã®è¨è¨
ããã ãã¦ããæ¥è¶³ãã¼ã¿ã®ãã©ã¼ããã
å·¦ããæ¥ä»ãéæã³ã¼ããå¸å ´åºåï¼1=æ±è¨¼ï¼é¨ï¼ãå§å¤ãé«å¤ãå®å¤ãçµå¤ãåºæ¥é«ã®é ã«ä¸¦ãã§ãããã¾ãã¯ãã®ãã¼ã¿ãæ ¼ç´ããSQLiteã®ãã¼ã¿ãã¼ã¹ãä½ããã¨ã«ãªããããã§Pythonãªãã§ã¯ã®SQLæä½ã¢ã¸ã¥ã¼ã«ãSQLObjectã
2006/01/04,1802,1,883,885,878,885,2543000
SQLObjectã¨ã¯
æ¥æ¬èªããã¥ã¡ã³ãã¯ãã¡ãã解説ããã»ã©çéãã¦ããªãã®ã§ãã¨ãããä¸è¨åã人ã®ãµã¤ããã©ããâ¦
ã¨ãã¨ãããããã°ã©ã
ãããMySQLã§è¨ãã¨ããã®CREATE TABLE stockPrice(date date,code INTEGERã以ä¸ç¥ãã«ç¸å½ãããã®ãSQLæã®ä»£ããã«ã¯ã©ã¹ãå®ç¾©ããæå¾ã«stockPrice.createTable()ã¨ããã¨ãã¼ãã«ãã§ããããªã¹ãå ¨æã¯ä»¥ä¸ã®éãã
class stockPrice(SQLObject):
date = DateCol()
code = IntCol()
market = IntCol()
stPrice = FloatCol()
hiPrice = FloatCol()
loPrice = FloatCol()
fnPrice = FloatCol()
dekiDaka = FloatCol()
- ã¢ã¸ã¥ã¼ã«ã¤ã³ãã¼ããã°ãã¼ãã«å¤æ°
# -*- coding: shift_jis -*-
from sqlobject import *
rootDir = '/Users/*****/Desktop/kabu/
- ãã¼ãã«å®ç¾©
class stockPrice(SQLObject):
date = DateCol()
code = IntCol()
market = IntCol()
stPrice = FloatCol()
hiPrice = FloatCol()
loPrice = FloatCol()
fnPrice = FloatCol()
dekiDaka = FloatCol()
- ãã¼ã¿ãã¼ã¹ã¸ã®æ¥ç¶é¢æ°
def connectDb():
connection_string = 'sqlite://' + rootDir + 'data.db'
connection = connectionForURI(connection_string)
sqlhub.processConnection = connection
- ãã¼ãã«ä½æé¢æ°
def initDb():
stockPrice.createTable()
- ã¡ã¤ã³ã«ã¼ãã³
if __name__ == '__main__':
connectDb()
initDb()