Pythonを用いて、MySQLに文章を挿入していきたいと考えています。
try: for i in range(t_df['text'].shape[0]): date = str(t_df['create_at'][i]) ret = str(t_df['text'][i]) cursor.execute("SELECT str_to_date('%s', '%%a %%b %%d %%T %%f %%Y')" % date) rows = cursor.fetchall() cursor.execute("SELECT DAYNAME('%s')" % rows[0][0]) week = cursor.fetchall() cursor.execute("INSERT into tweet(date, week, tweet) values('%s', '%s', '%s')" % (rows[0][0], week[0][0], ret)) db.commit() except: pass
以上のように、とりあえずMySQLにエスケープ処理などを気にせずに文章を挿入していきたいです。
しかし、try,exceptを実行しているのにも関わらず、途中で処理が停止してしまいます。
原因はどこにあるのでしょうか。
よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー