草庐IT

postgresql_psycopg

全部标签

python - 检查python下是否存在postgresql表(可能还有Psycopg2)

如何使用Psycopg2Python库确定表是否存在?我想要一个真或假bool值。 最佳答案 怎么样:>>>importpsycopg2>>>conn=psycopg2.connect("dbname='mydb'user='username'host='localhost'password='foobar'")>>>cur=conn.cursor()>>>cur.execute("select*frominformation_schema.tableswheretable_name=%s",('mytable',))>>>bool

python - 检查python下是否存在postgresql表(可能还有Psycopg2)

如何使用Psycopg2Python库确定表是否存在?我想要一个真或假bool值。 最佳答案 怎么样:>>>importpsycopg2>>>conn=psycopg2.connect("dbname='mydb'user='username'host='localhost'password='foobar'")>>>cur=conn.cursor()>>>cur.execute("select*frominformation_schema.tableswheretable_name=%s",('mytable',))>>>bool

python - 使用 psycopg2 无密码连接到数据库

我的本​​地主机上有一个postgres数据库,无需密码即可访问$psql-dmwtpsql(8.4.12)Type"help"forhelp.mwt=#SELECT*fromvatid;id|requester_vatid|...-----+-----------------|...1719|IT00766780266|...我想从django访问该数据库。所以我把DATABASESDATABASES={'default':{'ENGINE':'django.db.backends.postgresql_psycopg2','NAME':'mwt','USER':'shaoran',

python - 使用 psycopg2 无密码连接到数据库

我的本​​地主机上有一个postgres数据库,无需密码即可访问$psql-dmwtpsql(8.4.12)Type"help"forhelp.mwt=#SELECT*fromvatid;id|requester_vatid|...-----+-----------------|...1719|IT00766780266|...我想从django访问该数据库。所以我把DATABASESDATABASES={'default':{'ENGINE':'django.db.backends.postgresql_psycopg2','NAME':'mwt','USER':'shaoran',

python - 在 psycopg2 中将表名作为参数传递

我有以下代码,使用pscyopg2:sql='select%sfrom%swhereutctime>%sandutctime这个输出:select'waterTemp,airTemp,utctime'from'ss2012_t02'whereutctime>'2012-05-03T17:01:35+00:00'::timestamptzandutctime当我执行此操作时,它会倒下-这是可以理解的,因为表名周围的引号是非法的。有没有办法合法地将表名作为参数传递,或者我需要做一个(明确警告)字符串连接,即:voyage='ss2012_t02'sql='select%sfrom'+voy

python - 在 psycopg2 中将表名作为参数传递

我有以下代码,使用pscyopg2:sql='select%sfrom%swhereutctime>%sandutctime这个输出:select'waterTemp,airTemp,utctime'from'ss2012_t02'whereutctime>'2012-05-03T17:01:35+00:00'::timestamptzandutctime当我执行此操作时,它会倒下-这是可以理解的,因为表名周围的引号是非法的。有没有办法合法地将表名作为参数传递,或者我需要做一个(明确警告)字符串连接,即:voyage='ss2012_t02'sql='select%sfrom'+voy

python - 在 Mac OS (Yosemite) 上使用 psycopg2 的问题

目前我正在使用python安装psycopg2以便在eclipse中工作。我发现了很多问题:第一个问题sudopip3.4installpsycopg2不工作,显示如下信息Error:pg_configexecutablenotfound.修复:exportPATH=/Library/PostgreSQL/9.4/bin/:"$PATH"当我在我的项目中导入psycopg2时,我得到:ImportError:dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psyco

python - 在 Mac OS (Yosemite) 上使用 psycopg2 的问题

目前我正在使用python安装psycopg2以便在eclipse中工作。我发现了很多问题:第一个问题sudopip3.4installpsycopg2不工作,显示如下信息Error:pg_configexecutablenotfound.修复:exportPATH=/Library/PostgreSQL/9.4/bin/:"$PATH"当我在我的项目中导入psycopg2时,我得到:ImportError:dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psyco

PostgreSQL忘记postgres账号密码的解决方法

postgresql简介postgresql是一个功能非常强大的、源代码开放的客户/服务器关系型数据库管理系统(rdbms)。postgresql最初设想于1986年,当时被叫做berkleypostgresproject。该项目一直到1994年都处于演进和修改中,直到开发人员andrewyu和jollychen在postgres中添加了一个sql(structuredquerylanguage,结构化查询语言)翻译程序,该版本叫做postgres95,在开放源代码社区发放。下面给大家介绍下postgresql忘记postgres密码的处理方法,具体内容如下所示:postgresql数据库中,

python - 如何使用 psycopg2 在 postgres 中获取表?

谁能解释一下如何获取当前数据库中的表?我正在使用postgresql-8.4psycopg2。 最佳答案 这对我有用:cursor.execute("""SELECTtable_nameFROMinformation_schema.tablesWHEREtable_schema='public'""")fortableincursor.fetchall():print(table) 关于python-如何使用psycopg2在postgres中获取表?,我们在StackOverflow上