昨天写了个STEEMSQL相关的帖子
<ul> <li><a href="https://steemit.com/cn/@oflyhigh/steemsql" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">第一次使用STEEMSQL查询谷哥点名数据 <p dir="auto">主要介绍了<strong><em>如何安装pymssql以及用<strong><em>中文关键字查询数据<br /> 因为我对MSSQL以及pymssql都不熟悉,所以使用过程中遇到了很多问题,限于篇幅,昨天没有过多讲述,今天整理一下,希望学习pymssql或者想使用STEEMSQL的朋友少走一些弯路。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://steemitimages.com/DQmeLZD8MonT9kRXc37bmCEL5xQcG6y5SeRDPFdVn5EGsPB/image.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/DQmeLZD8MonT9kRXc37bmCEL5xQcG6y5SeRDPFdVn5EGsPB/image.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/DQmeLZD8MonT9kRXc37bmCEL5xQcG6y5SeRDPFdVn5EGsPB/image.png 2x" /> <h4>查询所有数据库名 / Query all database names <p dir="auto">昨天我们帖子中说了<br /><br /> 但是很遗憾上边的链接信息不全,没有Database的信息<span> SteemSQL 官网地址: <a href="http://steemsql.com/" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">http://steemsql.com/ <p dir="auto">其实这不是大问题,因为数据库信息是可以自行获取的,查询语句如下:<br /> <code>SELECT Name FROM Master..SysDatabases ORDER BY Name <p dir="auto">示例代码 <pre><code>import pymssql conn = pymssql.connect(host ="sql.steemsql.com",user="steemit",password="steemit", charset="utf8") cur = conn.cursor() cur.execute("SELECT Name FROM Master..SysDatabases ORDER BY Name") rows = cur.fetchall() for row in rows: print(row[0]) <p dir="auto">结果如下: <pre><code>DBSteem master tempdb <p dir="auto">好了,DBSteem就是我们要的数据库啦。 <p dir="auto">(测试了一下,不选择数据库,居然也可以执行正常的查询,比如查询Comments表下的数据,莫非有默认设置?) <h4>查询数据库中所有数据表 / Query all data tables in the database <p dir="auto">我们知道了DBSteem是我们要用到的数据库,但是这个库下边都有哪些表呢? <p dir="auto">查询语句如下:<br /> <code>SELECT Name FROM DatabaseName..SysObjects Where XType='U' ORDER BY Name <ul> <li>XType='U':表示所有用户表; <li>XType='S':表示所有系统表; <p dir="auto">试着查一下DBSteem下的用户表<br /> <code>cur.execute("Select Name From DBSteem..SysObjects Where XType='U' order By Name")<br /> (查询当前数据库可以省略路径<code>DBSteem..) <p dir="auto">结果如下: <blockquote> <p dir="auto">Accounts<br /> Blocks<br /> Comments<br /> Tokens<br /> Transactions<br /> TxAccountCreates<br /> TxAccountRecovers<br /> TxAccountUpdates<br /> TxAccountWitnessProxies<br /> TxAccountWitnessVotes<br /> TxClaimRewardBalances<br /> TxComments<br /> TxCommentsOptions<br /> TxConverts<br /> TxCustoms<br /> TxDelegateVestingShares<br /> TxDeleteComments<br /> TxEscrowApproves<br /> TxEscrowDisputes<br /> TxEscrowReleases<br /> TxEscrowTransfers<br /> TxFeeds<br /> TxLimitOrders<br /> TxPows<br /> TxTransfers<br /> TxVotes<br /> TxWithdraws<br /> TxWithdrawVestingRoutes<br /> TxWitnessUpdates<br /> VOAuthorRewards<br /> VOCurationRewards<br /> VOFillConvertRequest<br /> VOFillOrders<br /> VOFillVestingWithdraws<br /> VOInterests<br /> VOShutdownWitnesses <p dir="auto">这样我们就知道哪些表可用啦。 <h4>查询数据表中的字段 / Query fields in a data table <p dir="auto">知道数据库了,知道数据表了,我们还要知道表中都有哪些字段,才能方便我们查询,不是吗? <p dir="auto">查询语句如下:<br /> <code>SELECT Name FROM DatabaseName..SysColumns WHERE id=Object_Id('TableName') <p dir="auto">来试试Comments表<br /> <code>cur.execute("SELECT Name FROM DBSteem..SysColumns WHERE id=Object_Id('Comments')")<br /> (查询当前数据库下的表可以省略路径<code>DBSteem..) <p dir="auto">结果如下: <blockquote> <p dir="auto">abs_rshares<br /> active<br /> active_votes<br /> allow_curation_rewards<br /> allow_replies<br /> allow_votes<br /> author<br /> author_reputation<br /> author_rewards<br /> beneficiaries<br /> body<br /> body_language<br /> body_length<br /> cashout_time<br /> category<br /> children<br /> children_abs_rshares<br /> created<br /> curator_payout_value<br /> depth<br /> dirty<br /> ID<br /> json_metadata <p dir="auto">last_payout<br /> last_update<br /> max_accepted_payout<br /> max_cashout_time<br /> mode<br /> net_rshares<br /> net_votes<br /> parent_author<br /> parent_permlink<br /> pending_payout_value<br /> percent_steem_dollars<br /> permlink<br /> promoted<br /> reblogged_by<br /> replies<br /> reward_weight <blockquote> <p dir="auto">root_comment<br /> root_title<br /> title<br /> total_payout_value<br /> total_pending_payout_value<br /> total_vote_weight<br /> TS<br /> url<br /> vote_rshares <h4>查询数据表中的字段详细信息 / Query fields details in a data table <p dir="auto">有了上述基础,我们可以进一步查询字段的详细信息<br /> 以<strong><em>TxComments表为例:<br /> <code>cur.execute("SELECT SysColumns.Name,SysTypes.Name,SysColumns.IsNullable,SysColumns.Length FROM SysColumns, SysTypes WHERE SysColumns.XUserType = SysTypes.XUserType AND SysColumns.Id = object_id('TxComments')") <p dir="auto">结果如下: <pre><code>ID int 0 4 tx_id int 0 4 author varchar 0 50 permlink varchar 0 512 parent_author varchar 0 50 parent_permlink varchar 0 512 title nvarchar 0 -1 body nvarchar 0 -1 json_metadata varchar 0 -1 timestamp datetime 0 8 <h1>结论 / Conclusions <p dir="auto">我们探讨了如何通过SQL语句 <ul> <li>查询数据库名 / Query all database names <li>查询数据库中所有数据表 / Query all data tables in the database <li>查询数据表中的字段 / Query fields in a data table <li>查询数据表中的字段详细信息 / Query fields details in a data table <p dir="auto">通过了解这些信息,便于我们更好的实现我们的查询程序。<br /> 图形界面的程序,应该都会内置这些功能,大家不想深入了解的话,直接使用图形界面程序最方便了。 <hr /> <p dir="auto">以上内容仅供参考,如有错漏欢迎指正。使用pymssql以及STEEMSQL的一点经验
7 years ago in #cn by oflyhigh (85)
$274.05
- Past Payouts $274.05
- - Author $226.39
- - Curators $47.67
266 votes
- abit: $141.01
- linuslee0216: $22.57
- nicolemoker: $14.58
- sweetsssj: $9.97
- htliao: $9.40
- oflyhigh: $8.23
- trafalgar: $6.39
- livingfree: $6.29
- somebody: $4.69
- jackkang: $4.54
- tumutanzi: $4.53
- nextgen622: $4.31
- deanliu: $3.26
- xiaohui: $3.23
- ebejammin: $2.29
- arama: $2.12
- geoffrey: $2.05
- ethansteem: $1.91
- ace108: $1.88
- rok-sivante: $1.63
- and 246 more
Thanks :)
Damn I thought this was a new vaporwave artist... :P
I agree with everything you say here, very good post.I would like to know why if you actually think all this happens why have you no confidence in Steem?You transfer everything you make in SBD to an exchange to dump as soon as you make it here.You are not in full power up for the long haul and huge gains you speak of, but you believe this all blows up to mega numbers from where it is now?
love it
can i find somewhere the english version?
Posted it. check out my reply it is just google translate but I think it gets the job done.
区块信息是不是就是在block这个表里啊。那是不是可以通过这个知道指定用户 某段时间的所有操作
我还没仔细研究
不过直接通过Block查操作可能效率不高
通过TxXXXXX这些表查对应的操作会比较高效
신청합니다 !
hello my dear friend i like computer thanks alot please visit my page and upvote me i need help you
我不是這方面人才,只好默默支持😂
😄我也不是人才,初学者而已
已比我強了~枉我當年还是电子工程本科...完全看不懂...
有空了我也参照你这文章研究下
You Just Keep Amazing Me With Your Ability To Use Multiple Programming Languages And Passing Your Knowledge To The Steemit Community, Thanks Alot @oflyhigh :)
谢谢分享^^
muchas gracias!!
Thanks !! Learning more every day... half of it I still don't understand, but I'm sure I'll figure it out eventually... lol :)
还好用SQLDeveloper没有这样烦恼但是谢谢因为收集了做资料。:-)
EEverything about Chineeze is fascinating
Your post was mentioned in the hit parade in the following category:Congratulations @oflyhigh!