こんにちは、 @shogoです。 本日はPythonによるSteemSQLの利用方法について書いてみます。 日本語情報はなく、ほんの少し大変なので参考になりましたら幸いです。 # [SteemSQL](https://steemsql.com/) <center>  </center> 以前は無料で使えたのですが、現在はサブスクリプションモデルに移行しました。 10SBD/月 OR 1SBD/日 を選ぶことができます。 <center>  </center> 登録方法は簡単で、 @steemsqlにSBDを送るだけです。 メモは必要ありません。 <center>  </center> <center>  </center> 送信後、すぐに0.001SBDが返ってきます。 メモに、サーバー名、データベース名、ユーザーID、パスワードが記載されているので保存しておきます。 <center>  </center> ### 準備 ① ODBCドライバーをインストールします。 https://docs.microsoft.com/ja-jp/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-2017 ② pypyodbcを次のコマンドでInstallします。 ``` pip install pypyodbc ``` <br> 以下は[こちら](https://steemsql.com/steemsql-for-python-programmers/)に記載されている、SteemSQLに接続するサンプルコードです。 サーバー名、データベース名、ユーザーID、パスワードを送られてきたメモ通りに入力します。 ### connect.py ``` import pypyodbc connection = pypyodbc.connect('Driver={ODBC Driver 13 for SQL Server};' 'Server=************;' 'Database=**********;' 'uid=***************;pwd=****************') cursor = connection.cursor() SQLCommand = ("SQLクエリを入力する(Microsoft SQL)”) cursor.execute(SQLCommand) connection.close() ``` <br> 次は、実際にクエリを書いてみます。 ### example.py ``` import pypyodbc import pprint connection = pypyodbc.connect('Driver={ODBC Driver 13 for SQL Server};' 'Server=***************;' 'Database=************;' 'uid=******************;pwd=*******************') cursor = connection.cursor() SQLCommand = ("SELECT author, permlink FROM TxVotes WHERE voter = 'shogo';") result = cursor.execute(SQLCommand) result = result.fetchmany(100) pprint.pprint(result) connection.close() ``` ### 実行結果 <center>  </center> --- いかがでしたでしょうか?? 細かいところは端折りましたが、分からない部分が御座いましたらご連絡ください! Steem On!, @shogo
author | shogo |
---|---|
permlink | python-steemsql |
category | japanese |
json_metadata | {"community":"busy","app":"busy/2.5.6","format":"markdown","tags":["japanese","busy","steem","steemit","steemsql"],"users":["shogo","steemsql"],"links":["/@shogo","https://steemsql.com/","/@steemsql","https://docs.microsoft.com/ja-jp/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-2017","https://steemsql.com/steemsql-for-python-programmers/","/@shogo"],"image":["https://cdn.steemitimages.com/DQmT7QDBhrQQTmb3tjUWKFaCFMrRyyCRxM34rKkiLHtg4Zu/steemsql.PNG","https://cdn.steemitimages.com/DQmT3aGj26nj858YyrefkrKHwdLJSim6iacUTt7SrEWXmkY/steemsql1.PNG","https://cdn.steemitimages.com/DQmaK3yDyMfkmvXN5bYaB8DinDRBXoAiciiKugSd1bbg9ja/steemsql2.PNG","https://cdn.steemitimages.com/DQmSxvvc8146J3LiimxS5eEZp7n2opcJPb4UcFSiNxqyxoy/steemsql3.PNG","https://cdn.steemitimages.com/DQmU4JFMvUqSry5ntB98PcxBnLfFsMDtwFkGYqt5xGycVHC/Inkedsteemsql5_LI.jpg","https://cdn.steemitimages.com/DQmb2AgQzBWMH5oyuBxycJp2T5B67gw6pKQXwvM6XN2Y5Kz/result.PNG"]} |
created | 2018-12-08 17:42:06 |
last_update | 2018-12-08 17:54:18 |
depth | 0 |
children | 4 |
last_payout | 2018-12-15 17:42:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 3.422 HBD |
curator_payout_value | 0.930 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 2,519 |
author_reputation | 63,776,063,283,749 |
root_title | PythonによるSteemSQLの利用方法 |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 76,553,092 |
net_rshares | 7,396,507,719,812 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
matt-a | 0 | 806,448,641,247 | 25% | ||
knozaki2015 | 0 | 333,521,752,398 | 15% | ||
noopu | 0 | 47,192,536,762 | 40% | ||
yoshiko | 0 | 786,589,350,850 | 100% | ||
sirwinchester | 0 | 37,169,485,593 | 15% | ||
xanoxt | 0 | 10,511,355,738 | 5% | ||
zahnspange | 0 | 350,509,412,438 | 15% | ||
fukako | 0 | 27,579,546,681 | 96% | ||
busy.pay | 0 | 259,754,987,644 | 1.25% | ||
ultraseven | 0 | 78,997,023,163 | 35% | ||
rt395 | 0 | 13,649,342,204 | 40% | ||
jassennessaj | 0 | 16,464,126,309 | 5% | ||
kinakomochi | 0 | 83,268,188,160 | 50% | ||
djynn | 0 | 24,992,718,528 | 30% | ||
kayoko | 0 | 33,079,199,203 | 60% | ||
kuroneko | 0 | 43,626,083,099 | 100% | ||
steemitjp | 0 | 439,673,126,209 | 100% | ||
ichigo | 0 | 16,416,400,685 | 100% | ||
yasu24 | 0 | 14,924,697,572 | 15% | ||
moromaro | 0 | 57,437,111,284 | 50% | ||
hiradate | 0 | 15,481,962,786 | 40% | ||
exhige | 0 | 312,787,025 | 10% | ||
tonpa | 0 | 8,825,439,342 | 30% | ||
shogo | 0 | 160,177,882,767 | 100% | ||
argon | 0 | 117,168,591,705 | 30% | ||
ace69 | 0 | 2,114,789,088 | 50% | ||
youko | 0 | 2,630,113,217 | 100% | ||
sho-t | 0 | 7,706,623,105 | 20% | ||
jrvacation | 0 | 35,279,408,477 | 30% | ||
nadeshiko | 0 | 7,298,938,396 | 15% | ||
steemit-jp | 0 | 3,024,936,171,313 | 30% | ||
fun2learn | 0 | 1,490,658,963 | 1.6% | ||
jsj1215 | 0 | 63,537,306,770 | 9% | ||
shimaris | 0 | 4,686,401,641 | 50% | ||
yasu | 0 | 44,849,294,776 | 14% | ||
rocketmen | 0 | 5,802,584,950 | 15% | ||
rocketgirl | 0 | 5,839,419,580 | 15% | ||
hilty | 0 | 2,518,295,528 | 100% | ||
steemitbae | 0 | 29,718,553,475 | 100% | ||
tinkerbell-luv | 0 | 2,097,737,161 | 100% | ||
sallyfun | 0 | 14,021,731,735 | 41% | ||
yo-yo | 0 | 9,676,182,274 | 10% | ||
aki-kuraoka | 0 | 384,472,224 | 100% | ||
m0t0k1ch1 | 0 | 1,362,758,836 | 100% | ||
sumomo | 0 | 928,993,401 | 15% | ||
izzy7 | 0 | 72,040,778 | 100% | ||
nailyourhome | 0 | 1,521,898,711 | 1.6% | ||
ytrphoto | 0 | 197,393,112,883 | 15% | ||
steemit.japan | 0 | 3,044,256,592 | 15% | ||
steemit-japan | 0 | 2,838,862,147 | 15% | ||
tradingqueen | 0 | 9,384,057,269 | 15% | ||
hiroharry | 0 | 463,558,812 | 100% | ||
chihaha | 0 | 630,498,032 | 100% | ||
tokyo2018 | 0 | 554,195,243 | 100% | ||
delegate4upvot | 0 | 1,526,773,921 | 1.6% | ||
fujisan | 0 | 5,675,888,699 | 100% | ||
brian111 | 0 | 182,389,923 | 100% | ||
japanese-gourmet | 0 | 2,993,477,067 | 15% | ||
ryuhei | 0 | 1,683,553,191 | 100% | ||
eita | 0 | 9,143,583,220 | 100% | ||
yusaku | 0 | 8,429,420,106 | 100% | ||
glastar | 0 | 28,800,085,005 | 17.5% | ||
tamito0201 | 0 | 2,165,168,230 | 100% | ||
jp-tiger | 0 | 49,816,508,378 | 100% | ||
steem-man1 | 0 | 551,399,257 | 100% | ||
serinuntius | 0 | 11,441,878,007 | 100% | ||
knozaki2016 | 0 | 7,542,930,039 | 15% |
なるほど! ありがとうショウゴくん<3 まだまだですけど、めっちゃ参考になるの
author | fukako |
---|---|
permlink | re-shogo-python-steemsql-20181208t194243201z |
category | japanese |
json_metadata | {"tags":["japanese"],"app":"steemit/0.1"} |
created | 2018-12-08 19:42:42 |
last_update | 2018-12-08 19:42:42 |
depth | 1 |
children | 1 |
last_payout | 2018-12-15 19:42:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.028 HBD |
curator_payout_value | 0.009 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 39 |
author_reputation | 26,713,387,748,220 |
root_title | PythonによるSteemSQLの利用方法 |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 76,557,100 |
net_rshares | 62,080,711,716 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
shogo | 0 | 62,080,711,716 | 39% |
参考になったら嬉しいです!! 僕もまだまだですが、勉強します :)
author | shogo |
---|---|
permlink | re-fukako-re-shogo-python-steemsql-20181209t072816019z |
category | japanese |
json_metadata | {"tags":["japanese"],"app":"steemit/0.1"} |
created | 2018-12-09 07:28:18 |
last_update | 2018-12-09 07:28:18 |
depth | 2 |
children | 0 |
last_payout | 2018-12-16 07:28:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 33 |
author_reputation | 63,776,063,283,749 |
root_title | PythonによるSteemSQLの利用方法 |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 76,576,543 |
net_rshares | 0 |
ありがとうございます! 参考になります! ちなみに、Steem Trackedというのも気になっているのですが、リンクが切れてしまっているようです^^; https://steemit.com/@steemtracked
author | sho-t |
---|---|
permlink | re-shogo-python-steemsql-20181209t083842094z |
category | japanese |
json_metadata | {"tags":["japanese"],"links":["https://steemit.com/@steemtracked"],"app":"steemit/0.1"} |
created | 2018-12-09 08:38:42 |
last_update | 2018-12-09 08:38:42 |
depth | 1 |
children | 1 |
last_payout | 2018-12-16 08:38:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 111 |
author_reputation | 4,284,977,069,948 |
root_title | PythonによるSteemSQLの利用方法 |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 76,578,532 |
net_rshares | 0 |
ありがとうございます :) Steem Trackedは初めて知りました! 少し触ってみたかったです :D
author | shogo |
---|---|
permlink | re-sho-t-re-shogo-python-steemsql-20181210t151014329z |
category | japanese |
json_metadata | {"tags":["japanese"],"app":"steemit/0.1"} |
created | 2018-12-10 15:10:15 |
last_update | 2018-12-10 15:10:15 |
depth | 2 |
children | 0 |
last_payout | 2018-12-17 15:10:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 53 |
author_reputation | 63,776,063,283,749 |
root_title | PythonによるSteemSQLの利用方法 |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 76,641,214 |
net_rshares | 0 |