GVKun编程网logo

postgres和postgresql_psycopg2作为django的数据库引擎有什么区别?

11

如果您对postgres和postgresql_psycopg2作为django的数据库引擎有什么区别?感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于postgres和po

如果您对postgres和postgresql_psycopg2作为django的数据库引擎有什么区别?感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于postgres和postgresql_psycopg2作为django的数据库引擎有什么区别?的详细内容,并且为您提供关于centos 7下源码编译安装php支持PostgreSQL postgresql手册 postgresql官网下载 postgresql视频教、Django postgres连接,为psycopg2设置时区、OSX上的psycopg2:我也必须安装PostgreSQL吗?、Postgres SQL中的`->>`和`->`有什么区别?的有价值信息。

本文目录一览:

postgres和postgresql_psycopg2作为django的数据库引擎有什么区别?

postgres和postgresql_psycopg2作为django的数据库引擎有什么区别?

我已经使用python一段时间了,但是从未使用过django。我要接管另一个员工在离开我们公司之前所做的项目。我想知道在选项postgresql和postgresql_psycopg2作为django的数据库驱动程序之间是否有区别。

在有关如何设置Django项目的一些文章和文档中,我仅看到了postgresql,而在另一些文章中,我看到了postgresql_psycopg2。我在文档(此处
或此处)中找不到提及psycopg2的任何内容,所以这只是编写该选项的旧方法吗?

一个只是另一个的别名,还是它们实际上是不同的?我也找不到关于此的任何其他问题。

DATABASES = {''default'': {    ''ENGINE'': ''django.db.backends.postgresql'',# here I also saw postgres_psycopg2    ''NAME'': ''premqcsite'',    ''USER'': ''django_user'',    ''PASSWORD'': ''Encepta_123'',    ''HOST'': ''localhost'',    ''PORT'': ''5432'',}}

答案1

小编典典

一样的。django.db.backends.postgresql_psycopg2在django <1.8中使用,并在django
1.9中重命名为django.db.backends.postgresql。从文档:

在Django 1.9中进行了更改:

在较早的版本中,django.db.backends.postgresql后端被命名为django.db.backends.postgresql_psycopg2。为了向后兼容,旧名称在新版本中仍然有效。

centos 7下源码编译安装php支持PostgreSQL postgresql手册 postgresql官网下载 postgresql视频教

centos 7下源码编译安装php支持PostgreSQL postgresql手册 postgresql官网下载 postgresql视频教

1. 下载源码

$ mkdir /usr/downloads
$ wget -c http://cn2.php.net/distributions/php-5.6.20.tar.gz
$ tar -xvf php-5.6.20.tar.gz
$ mv php-5.6.20 /usr/local/src
$ cd !$ &amp; cd php-5.6.20
登录后复制

2. 阅读安装指导

$ ls -also
$ less README
$ less INSTALL
登录后复制

3. 安装依赖包

$ yum install apr apr-util apr-devel apr-util-devel prce lynx
登录后复制

4. 安装httpd

$ wget -c http://apache.fayea.com//httpd/httpd-2.4.20.tar.gz
$ tar -xvf httpd-2.4.20.tar.gz
$ cd httpd-2.4.20
$ ./configure \
--prefix=/usr/local/programs/apache2 \
--enable-rewrite \
--enable-so \
--enable-headers \
--enable-expires \
--with-mpm=worker \
--enable-modules=most \
--enable-deflate \
--enable-module=shared
$ make
$ make install
$ cd /usr/local/programs/apache2
$ cp bin/apachectl /etc/init.d/httpd ## 复制启动脚本
$ /etc/init.d/httpd start ## 启动apache服务器,访问http://localhost/
$ egrep -v ''^[ ]*#|^$'' /usr/local/apache2/conf/httpd.conf | nl ## 查看apache服务器的配置
## 将apache加入系统服务
vi /etc/rc.d/rc.local
```
/usr/local/programs/apache2/bin/apachectl start
```
$ cat /etc/rc.local
登录后复制

4. 安装postgresql

立即学习“PHP免费学习笔记(深入)”;

$ yum install readline-devel  ## 安装readline依赖
$ cd /usr/downloads
$ wget -c https://ftp.postgresql.org/pub/source/v9.5.0/postgresql-9.5.0.tar.bz2
$ tar -xvf postgresql-9.5.0.tar.bz2
$ cd postgresql-9.5.0
$ ./configure --prefix=/usr/local/programs/postgresql
$ make
$ su
$ make install
$ /sbin/ldconfig /usr/local/programs/postgresql/lib ## 刷新下共享动态库
$ cd /usr/local/programs/postgresql
$ bin/psql --version  ## 检查运行情况
## 开始对postgresql的配置
$ vi /etc/profile.d/postgresql.sh ## 增加环境变量,不推荐直接在/etc/profile中添加,系统更新升级时会需要merge
``` 
PATH=/usr/local/programs/postgresql:$PATH
export PATH
```
$ source /etc/profile ## 更新环境变量

## 增加用户和其他文件夹
$ adduser postgres
$ passwd postgres 
$ mkdir /usr/local/programs/postgresql/logs
$ mkdir /usr/local/programs/postgresql/data
$ chown postgres /usr/local/programs/postgresql/data
$ su - postgres

## 初始化数据库
$ ./bin/initdb -D ./data
$ ./bin/createdb test
$ ./bin/psql test
## 已有数据库,可导入data文件夹后尝试root访问,假如带密码,可能需要进一步研究下
$ ./bin/postgres -D ./data &gt;./logs/start-log-1.log 2&gt;&amp;1 &amp;
$ ./bin/psql --list  ##列出数据库
## ok,安装完成

## 自定义设置,权限控制等,可以跳过,等熟悉使用后再做
## 编辑数据库配置及权限文件:
$ vi /usr/local/programs/postgresql/data/postgresql.conf   ## 数据库配置文件
$ chown postgres postgresql.conf
$ chmod 644 postgresql.conf
$ vi /usr/local/programs/postgresql/data/pg_hba.conf   ## 权限文件
$ vi /usr/local/programs/postgresql/data/pg_ident.conf

## 设置开机自启动:
$ vi /etc/rc.d/rc.local    ## 添加如下内容
```
/usr/local/programs/postgresql/bin/postgresql start
```
登录后复制

5. 安装php

## 源码已经在第一步中下载,现在开始安装:
$ yum install libxml2 libxml2-devel libpng libpng-devel libjpeg libjpeg-devel freetype freetype-devel
$ ./configure \
--prefix=/usr/local/programs/php \
--with-apxs2=/usr/local/programs/apache2/bin/apxs \
--with-zlib \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-zlib-dir \
--enable-mbstring \
--with-pgsql=/usr/local/programs/postgresql \
--with-pdo-pgsql=/usr/local/programs/postgresql 
$ make
$ make test
&gt; Bug #42718 (unsafe_raw filter not applied when configured as default filter) [ext/filter/tests/bug42718.phpt]  XFAIL REASON: FILTER_UNSAFE_RAW not applied when configured as default filter, even with flags
&gt; Bug #67296 (filter_input doesn''t validate variables) [ext/filter/tests/bug49184.phpt]  XFAIL REASON: See Bug #49184
&gt; Bug #53640 (XBM images require width to be multiple of 8) [ext/gd/tests/bug53640.phpt]  XFAIL REASON: Padding is not implemented yet
&gt; zend multibyte (7) [ext/mbstring/tests/zend_multibyte-07.phpt]  XFAIL REASON: https://bugs.php.net/bug.php?id=66582
&gt; zend multibyte (9) [ext/mbstring/tests/zend_multibyte-09.phpt]  XFAIL REASON: https://bugs.php.net/bug.php?id=66582
&gt;Bug #70470 (Built-in server truncates headers spanning over TCP packets) [sapi/cli/tests/bug70470.phpt]  XFAIL REASON: bug is not fixed yet

## 查阅官方的bug,发现:
&gt; id=66582: status : Closed. Fixed in master (PHP7)
&gt; id=42718: status : Assigned
&gt; id=42718: reference to id=49184, unsolved for many years
## 那就不关心了,直接装吧
$ make install
&gt; You may want to add: /usr/local/programs/php/lib/php to your php.ini include_path

## 那就按它说的设置吧
$ cp php.ini-development /usr/local/programs/php/lib/php.ini
```
include_path = ".;/usr/local/programs/php/lib/php"

## 然后,编辑httpd的设置,确保其能正确解析php文件
```
...
LoadModule php5_module modules/libphp5.so
...
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .php5

...
<ifmodule dir_module>
    DirectoryIndex index.html index.php
</ifmodule>     
```

## 重启httpd,测试
$ cd /usr/local/programs/apache2
$ bin/httpd -h
$ bin/httpd -k stop
$ bin/httpd -f conf/httpd.conf
## 默认设置的www页面在./htdocs/下,那就先去里面建一个测试页面吧
$ vi htdocs/index.php
```
<?php phpinfo(); ?>
```
$ curl http://localhost/index.php |grep postgresql
#ok
登录后复制

后续应该做的事

* 1. 启动时,不需要要手动指定配置文件
* 2. php初始化www目录设置
* 3. php 用户、权限管理等

'').addClass(''pre-numbering'').hide(); $(this).addClass(''has-numbering'').parent().append($numbering); for (i = 1; i '').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了centos 7下源码编译安装php支持PostgreSQL,包括了postgresql,centos 7方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Django postgres连接,为psycopg2设置时区

Django postgres连接,为psycopg2设置时区

首先打开一个SET timezone TO 'Asia/Tbilisi';查询,或者在打开连接之前设置PGTZ environment variable(如果需要从python进行设置,请使用os.environ)。您还可以发出ALTER DATABASEALTER ROLE并默认设置时区,如PGTZ的链接文档中所述,但我倾向于避免这种情况,因为这样做很容易忘记对于新的数据库/用户(&它也仅适用于新的连接;长时间运行的数据库/用户将具有连接时默认的TZ)。

OSX上的psycopg2:我也必须安装PostgreSQL吗?

OSX上的psycopg2:我也必须安装PostgreSQL吗?

我想从OS /X中的Python访问在远程计算机上运行的postgreSQL数据库。我也必须在Mac上安装postgres吗?否则psycopg2会自己工作。

有什么提示可以为OS / X提供适用于psycopg2的良好安装指南吗?

答案1

小编典典

macports告诉我psycopg2软件包对postgres客户端和库(而不是db服务器)具有依赖性。如果成功安装了psycopg,则应该一切顺利。

如果尚未安装,请考虑使用macports或fink为您处理依赖性解析。在大多数情况下,这会使事情变得容易(有时会引发问题)。

Postgres SQL中的`->>`和`->`有什么区别?

Postgres SQL中的`->>`和`->`有什么区别?

->>->SQL和有什么不一样?

在此线程中(检查json类型列postgresql中的字段是否存在),回答者基本上建议使用,

json->'attribute' is not null

代替,

json->>'attribute' is not null

为什么使用单箭头而不是双箭头?以我有限的经验,两者都做同样的事情。

今天关于postgres和postgresql_psycopg2作为django的数据库引擎有什么区别?的分享就到这里,希望大家有所收获,若想了解更多关于centos 7下源码编译安装php支持PostgreSQL postgresql手册 postgresql官网下载 postgresql视频教、Django postgres连接,为psycopg2设置时区、OSX上的psycopg2:我也必须安装PostgreSQL吗?、Postgres SQL中的`->>`和`->`有什么区别?等相关知识,可以在本站进行查询。

本文标签: