当前位置:网站首页>SQL statement--get database table information, table name, column name, description comment, etc.
SQL statement--get database table information, table name, column name, description comment, etc.
2022-08-11 00:49:00 【data wanderer】
information_schemaDetails
import pandas as pdimport reimport psycopg2from sqlalchemy import create_engine# Link library account informationgongsi_engine = psycopg2.connect(dbname='kk_dw',user='*******',password='*****',host='***')# Read the required data table from the company databasetable_data = pd.read_sql(r"select * from pg_tables where schemaname = 'dwd';",con=gongsi_engine)table_data.head()data = pd.read_sql(r"""select *from information_schema.columnswhere table_schema='dwd'and table_name='dwd_store_other_in_storage_orders_detail'""",con=gongsi_engine)data[['table_name','column_name','udt_name']]

Get a description, etc.
data = pd.read_sql(r"""selecta.attnum,n.nspname,c.relname,a.attname as field,t.typname as type,a.attlen as length,a.atttypmod as lengthvar,a.attnotnull as notnull,b.description as commentfrompg_namespace n left join pg_class con n.oid = c.relnamespaceleft join pg_attribute aon a.attrelid = c.oidleft join pg_description bon a.attrelid = b.objoid and a.attnum = b.objsubidleft join pg_type ton a.atttypid = t.oidwheren.nspname = 'dwd' --table_schemaand c.relname = 'dwd_store_o2o_sales_detail' -- table_nameand a.attnum > 0order bya.attnum;""",con=gongsi_engine)The function implemented in this way is that I can obtain information such as table names, fields and field descriptions in the database in batches.
边栏推荐
- Exception: try catch finally throws throw
- Jvm.分析工具(jconsole,jvisualvm,arthas,jprofiler,mat)
- PMP每日一练 | 考试不迷路-8.10(包含敏捷+多选)
- Web APIs BOM- 操作浏览器之综合案例
- WinForm(五)控件和它的成员
- postgresql参数意义
- rhel7.0解决yum无法使用(system is not registered to Red Hat Subscription Management)
- Where can I download IEEE papers?
- url转成obj或者obj转成url的方法
- ABP中的数据过滤器
猜你喜欢

Dump file generation, content, and analysis

BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection Paper Notes

"NIO Cup" 2022 Nioke Summer Multi-School Training Camp 3 DF Problem Solving

③ 关系数据库标准语言SQL 数据查询(SELECT)
![[Excel knowledge and skills] Convert](/img/96/ece9c3885fd4abe4bf4d211813b9c4.png)
[Excel knowledge and skills] Convert "false" date to "true" date format

input输入框超出部分用省略号表示以及判断内容是否有超出(PC端)

Use mysql statement to operate data table (table)

ABP中的数据过滤器

MySQL索引与事务

Web APIs BOM- 操作浏览器之综合案例
随机推荐
Dump文件生成,内容,以及分析
HW-常见攻击方式和漏洞原理(2)
Elastic scaling of construction resources
云原生-VMware虚拟机安装Kubesphere实战(一)
【openpyxl】过滤和排序
SQL语句--获取数据库表信息,表名、列名、描述注释等
"NIO Cup" 2022 Nioke Summer Multi-School Training Camp 4 ADHK Problem Solving
循环单词
线上突然查询变慢怎么核查
【考虫 六级英语】语法课笔记
分库分表ShardingSphere-JDBC笔记整理
YOLOv5的Tricks | 【Trick12】YOLOv5使用的数据增强方法汇总
dump_stack()
Only lazy and hungry. You still don't understand the singleton pattern!
从0开始设计JVM ,忘记名词跟上思路一次搞懂
Web APIs BOM- 操作浏览器之综合案例
sed of the Three Musketeers of Shell Programming
微信小程序通过URL Scheme动态的渲染数据
ADC和DAC记录
如何破坏Excel文件,让其显示文件已损坏方法