postgresql - 如何使用 psycopg2 获取 PostgreSQL 版本?

标签 postgresql psycopg2

我有以下声明:

from alembic import op
conn = op.get_bind()

现在我想获取postgresql版本。

最佳答案

根据文档,它是 server_version连接属性:

conn = psycopg2.connect(settings.DB_DSN)
>>> conn.server_version
90504

The number is formed by converting the major, minor, and revision numbers into two-decimal-digit numbers and appending them together. For example, version 8.1.5 will be returned as 80105.

关于postgresql - 如何使用 psycopg2 获取 PostgreSQL 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39447836/

相关文章:

python安装找不到psycopg2 ImportError

PostgreSQL group by date_trunc聚合索引大于不使用索引

postgresql - Azure PostgreSql 的性能很差

PostgreSQL 模式设计器

ruby-on-rails - 在构造 SQL 查询时,ActiveRecord 是否处理按值查找 `enum` ?

python - 执行命令时路径未添加到 $PATH 变量

python - 使用 psycopg2 执行大型查询

postgresql - 如何避免 postgres 弄乱实体的 ID

python - 苹果 M1 : install psycopg2 package Symbol not found: _PQbackendPID

python - Postgresql插入多列格式错误的数组文字