Ad
5: 2016-12-25 (日) 09:53:59 njf ソース バックアップ No.5 を復元して編集 現: 2017-09-17 (日) 14:57:55 njf ソース 編集
Line 2: Line 2:
MySQLのインストールは他にたくさん資料があるのでそちらを参照のこと。 MySQLのインストールは他にたくさん資料があるのでそちらを参照のこと。
-Macならバイナリダウンロードしてインストール、WindowsならWAMPとかVertrigoServが楽かもしれません。+Macならbrewコマンドかバイナリダウンロードしてインストール、WindowsならWAMPとかVertrigoServが楽かもしれません。
Linuxなどはパッケージ管理コマンドで簡単に入るはずです。 Linuxなどはパッケージ管理コマンドで簡単に入るはずです。
Line 19: Line 19:
 import MySQLdb  import MySQLdb
 + 
 connector = MySQLdb.connect(host="localhost",db = "python_test", user="myuser", passwd="mypassword", charset="utf8")  connector = MySQLdb.connect(host="localhost",db = "python_test", user="myuser", passwd="mypassword", charset="utf8")
 cursor = connector.cursor()  cursor = connector.cursor()
 + 
 cursor.execute(u"INSERT INTO test VALUE(1,'This is Test');")  cursor.execute(u"INSERT INTO test VALUE(1,'This is Test');")
 connector.commit()  connector.commit()
Line 60: Line 60:
 import MySQLdb  import MySQLdb
 + 
 connector = MySQLdb.connect(host="localhost",db = "python_test", user="myuser", passwd="mypassword", charset="utf8")  connector = MySQLdb.connect(host="localhost",db = "python_test", user="myuser", passwd="mypassword", charset="utf8")
 cursor = connector.cursor()  cursor = connector.cursor()
 cursor.execute("SELECT * FROM test;")  cursor.execute("SELECT * FROM test;")
 datas = cursor.fetchall()  datas = cursor.fetchall()
 + 
 for row in datas:  for row in datas:
   print row[0],row[1]    print row[0],row[1]


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード印刷に適した表示   ページ新規作成 全ページ一覧 単語検索 最新ページの一覧   ヘルプ   最新ページのRSS 1.0 最新ページのRSS 2.0 最新ページのRSS Atom Powered by xpWiki
Counter: 2086, today: 2, yesterday: 1
MenuBar
広告

ログイン

ユーザー名:


パスワード:





パスワード紛失

Portuguese | English | German | Greek | Japanese | Korean | Russian | T-Chinese top
NJF