【python使用post提交数据到远程url的方法】教程文章相关的互联网学习教程文章

python – 错误是:没有名为postgresql.base的模块【代码】

我正在尝试将Django应用程序迁移到postgresql,但我无法让Django认识到实际安装了postgres.我已将它安装在我的计算机上,并且它在我的计算机上正常运行,但当我尝试将其设置为我的settings.py中的默认值时,我收到错误:Error was: No module named postgresql.base我已经通过两次演练来获得运行Django here和here的postgresql,但我仍然遇到这个错误.我应该在我的虚拟环境中安装postgresql吗?我试过这样做,但没有运气. settings.pyDAT...

postgresql – 无法打开扩展控制文件plpython3u.control:没有这样的文件或目录【代码】

我想在我的postgresql数据库中使用python3来编写存储过程. 在psql客户端,当我输入命令create extension plpython3u时,我得到错误:couldn't open extension control file /usr/share/postgresql/9.1/extension/plpython3u.control : No such file or directory我已经检查过,目录中有plpythonu.control和plpython2u.control,但不是版本3的那个. 但是我从软件仓库安装了软件包python3和python3-postgresql(以及其他软件包).我正在使用...

postgresql – 为什么PL / Python不受信任?

根据文件:PL/Python is only available as an “untrusted” language, meaning it does not offer any way of restricting what users can do in it and is therefore named plpythonu. A trusted variant plpython might become available in the future if a secure execution mechanism is developed in Python.为什么难以为Python开发安全执行机制,而不是为其他语言(如Perl)开发?解决方法:它与Python的对象模型有关 – 总是...

是否有一种简单的捆绑方式来安装Django,Python,Apache,MySQL / PostreSQL?

我有很多网站,我通常喜欢用PHP / MySQL / Apache设置环境. 但是,现在我开始使用Django,它似乎不容易设置,当我这样做时,我必须使用sqlite并创建一堆bat文件来运行打包的开发服务器,并自行安装所有内容. (我在很多服务器上使用Windows). 但这很乏味,如果我想使用Apache而不是开发服务器,并且如果我想使用MySQL而不是sqlite(或postreSQL),则问题和步骤会变得更加复杂.事实上,我甚至认为你不能轻易地让MySQL和Django一起工作,因为mysql...

python – Postgresql表更新【代码】

我使用python中的postgresql更新了一个数据库表我的代码是import psycopg2 connection=psycopg2.connect("dbname=homedb user=ria") cursor=connection.cursor() l_dict= {'licence_id':1} cursor.execute("SELECT * FROM im_entry.usr_table") rows=cursor.fetchall()for row in rows:i=i+1p = findmax(row)#print pidn="id"idn=idn+str(i)cursor.execute("UPDATE im_entry.pr_table SET (selected_entry) = ('"+p+"') WHERE ima...

python – PostgreSQL NUMERIC数据类型的Django模型字段【代码】

我正在使用Django创建一个需要列数字(15,6)的应用程序(使用PostgreSQL),但我找不到这样做的方法.解决方法:来自PostgreSQL文档:The types decimal and numeric are equivalent. Both types are part of the SQL standard.所以你可以使用Django的DecimalFieldclass MyModel(models.Model):my_field = models.DecimalField(max_digits=15, decimal_places=6)一些文档: > http://www.postgresql.org/docs/current/interactive/dataty...

python – 使用postgresql数据库时uwsgi下的django app无法启动【代码】

我在AWS上的Ubuntu 14.04中设置了一个应用程序 – > NGINX – > UWSGI – > DJANGO APP.当使用sqllite3时,应用程序运行完全正常,但是当我使用django.db.backends.postgresql_psycopg2w作为我的数据库引擎时,它无法加载,我在uwsgi日志中找到了这个:- *** Starting uWSGI 2.0.12 (64bit) on [Mon Jan 18 05:36:25 2016] ***- compiled with version: 4.8.4 on 18 January 2016 04:10:30- os: Linux-3.13.0-48-generic #80-Ubuntu ...

python – PostgreSQL程序语言:选择?

我一直在使用PostgreSQL,玩维基百科的数百万个超链接等等,已经有2年了.我要么直接通过发送SQL命令来做我的事情,要么我在python中编写客户端脚本来管理一百万个查询,这时无法有效地(高效地)有效地完成. 我会在我的32位笔记本电脑上运行我的python脚本并让它与运行PostgreSQL的6000美元64位服务器通信;因此,我将有额外的2.10 Ghz,3 GB的RAM,psyco和多线程SQL查询管理器. 我现在意识到现在是我升级的时候了.我需要使用过程语言(PL)学习...

python – Flask和SQLalchemy NoForeignKeysError:无法确定关系User.posts上的父/子表之间的连接条件【代码】

我开始使用Mega Flask教程来构建一个简单的博客风格网站.我用这个与一些python学习相关,试图加强我学到的东西.为了更多地学习,我决定将教程弃用OAuth登录文章转换为传统的登录栏.当我尝试登录时,我遇到了一个问题. NoForeignKeysError:无法确定关系User.posts上的父/子表之间的连接条件 – 没有链接这些表的外键.确保引用列与ForeignKey或ForeignKeyConstraint相关联,或指定“primaryjoin”表达式. 由于我对Python的理解有限,我在...

python – celery,postgresql – >配置后端【代码】

所以我只是开始使用芹菜并尝试做一些简单的测试来感受它.我试图设置芹菜使用postgres为我的后端.在本页面:http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html#keeping-results我看到了这个例子celery = Celery('tasks', backend='redis://localhost', broker='amqp://')所以在我的代码中我试试celery = Celery('tasks', backend='sqla+postgresql://celery_exp:celery_exp@myhost/celery_exp...

Postgresql Python:忽略重复键异常【代码】

我按以下方式使用psycopg2插入项目:cursor = connection.cursor() for item in items:try:cursor.execute("INSERT INTO items (name, description) VALUES (%s, %s) RETURNING id",(item[0], item[1]))id = cursor.fetchone[0]if id is not None:cursor.execute("INSERT INTO item_tags (item, tag) VALUES (%s, %s) RETURNING id",(id, 'some_tag')) except psycopg2.Error:connection.rollback()print("PostgreSQL Error: ...

为什么我不能安装psycopg2? (Python 2.6.4,PostgreSQL 8.4,OS X 10.6.3)【代码】

原始消息(现已过时): 运行python setup.py install后,我得到以下内容:Warning: Unable to find 'pg_config' filebuilding 'psycopg2._psycopg' extension gcc-4.0 -arch ppc -arch i386 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 - DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.1 (dt dec ext pq3)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/...

python – 将值列表插入PostgreSQL【代码】

我正在尝试将值列表插入到PostgreSQL数据表中. 我有这个名为rows的数组,它显示如下:for row in rows:print(row)(249607, 15802) (249612, 15802) (249613, 15802) (249614, 15802) (249615, 15802) (249616, 15802) (249617, 15802) (249619, 15802) (249620, 15802)我试图将它插入我的表中,如下所示:for row in rows:cur.execute("INSERT INTO myTable (id1, id2, key, value) VALUES (%s, %s, %s, %s)" , (row[0], row[1]...

python – Django Postgresql syncdb错误【代码】

当我运行python manage.py syncdb时,我收到此错误:OperationalError: could not translate host name "localhost" to address: nodename nor servname provided, or not known我的settings.py文件如下所示:if "IS_STAGING" in os.environ or "IS_PRODUCTION" in os.environ:import dj_database_urlDATABASES = {'default':dj_database_url.config(default='postgres://localhost')} else:DATABASES = {'default': {'ENGINE': 'dj...

python – django postgresql OperationalError:索引行大小xxx超过最大yyy【代码】

我正在尝试学习一些django并尝试在数据库中插入一些值(使用模型表单),但这似乎没有引用:django.db.utils.OperationalError: index row size 3008 exceeds maximum 2712 for index "appname_mymodel_ggg_like"我的模型很简单,看起来像这样:class myModel(TimeStampedModel):fff = models.URLField(db_index=False, blank=False,primary_key=False) ggg = models.TextField(db_index=False, blank=False,primary_key=False)mj = m...