INVESTAR / StockAnalysisInPython

452 stars 411 forks source link

5.4.7 Analyzer.MarketDB() #162

Open bettertofly opened 1 year ago

bettertofly commented 1 year ago

안녕하세요~ 선생님~ 파이썬 증권데이터 분석 책 구입해서 잘 보고있는 독자입니다. 책이 처음부터 자세히 잘 정리가 되어있어서 지금껏 잘 따라가고 있습니다. 그러다가 난관에 부딧혀서 글을 남깁니다.

책 p.248 에서 mk = Analyzer.MarketDB() 이렇게 하면 오류가 떠서 pip install SQLAlchemy pip install lxml 등 여기 저기서 찾아봐도 계속해서 아래와 같은 오류 메시지가 뜨는데 혹시 뭔지 알수 있을까요?

UserWarning: pandas only support SQLAlchemy connectable(engine/connection) ordatabase string URI or sqlite3 DBAPI2 connectionother DBAPI2 objects are not tested, please consider using SQLAlchemy

==================================================================================== Microsoft Windows [Version 10.0.19044.1889] (c) Microsoft Corporation. All rights reserved.

C:\Users\KJH>cd..

C:\Users>cd..

C:>cd myPackage

C:\myPackage>python Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

from Investar import Analyzer mk = Analyzer.MarketDB() C:\Users\KJH\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\sql.py:761: UserWarning: pandas only support SQLAlchemy connectable(engine/connection) ordatabase string URI or sqlite3 DBAPI2 connectionother DBAPI2 objects are not tested, please consider using SQLAlchemy warnings.warn(

====================================================================================

INVESTAR commented 1 year ago

DB 커넥션과 관련된 경고인 것 같으니, 먼저 pymysql이 설치되어 있는지 확인해 보시고 220 페이지의 마리아디비 접속 테스트 코드가 동작하는지부터 확인해 보시는 게 좋겠습니다.

#ch05_03_SelectVersion.py
import pymysql
connection = pymysql.connect(host='localhost', port=3306, db='INVESTAR',
user='root', passwd='myPa$$word', autocommit=True) # ①
cursor = connection.cursor() # ②
cursor.execute("SELECT VERSION();") # ③
result = cursor.fetchone() # ④
print ("MariaDB version : {}".format(result))
connection.close()

MariaDB version : ('10.5.1-MariaDB',)

wingmin2 commented 1 year ago

저두 마리아디비 접속 테스트 코드가 동작은 하는데

C:\mypackage\Investar\Analyzer.py:23: UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy. krx = pd.read_sql(sql, self.conn)

라는 에러가 계속 생기네요

앞의 내용 확인 후 pip install 해 보았고, 날짜 또한 변경해서 해보았는데 똑같은 에러가 계속 나오네요