使用postgresql的处理程序扩展collective.easyform

collective.fgrcon.pgeasyform的Python项目详细描述


这个插件扩展了collective.easyform(https://pypi.org/project/collective.easyform/),提供了在postgresql数据库中存储表单数据的方法

功能

  • 新表单操作:“postgres data”和相应的postgrestahandler。 操作配置字段:数据库连接字符串、数据库表名、小数分隔符 数据库连接字符串示例:dbname='postgres'user=='postgres',host='localhost' password = 'secret'

    选择十进制分隔符时,逗号也被视为十进制分隔符(对设备有帮助)

  • 如果数据库表中不存在数据库表,它将被创建:

    • 创建Postgres数据表单操作

    • 定义表单域

    • 用示例数据填写表单的所有字段一次,然后提交表单

      数据库表将以plone字段id作为列名的方式生成, postgres数据类型相应地映射到表单字段的python数据类型。 将自动生成列名称为“_id_u”的主键字段(串行)。这允许查看和编辑 使用pgadmin4(https://www.pgadmin.org)等工具的数据

Postgres

您可以连接到任何Postgres服务器(本地主机或远程)。这个插件已经用postgres v 10测试过了。

另一个让postgres启动并运行的简单方法是使用docker:

  • Install docker

  • ^{tt2}$ tag e. g.110.5

    Without ^{tt3}$ this will pull down the latest stable release Postgres image from the official Postgres docker hub repository.

  • 创建一个目录作为postgres数据文件的本地主机装载点 如果我们想将postgres实例生成的数据持久化到容器生命周期之外的容器中,我们需要将本地装入点作为数据卷映射到容器中的适当路径。通常,我会在主目录中创建一个卷文件夹(我们可以为该文件夹指定任何名称),然后为需要为其创建数据卷装入点的每个应用程序创建子文件夹。

    mkdir -p $HOME/docker/volumes/postgres

  • 运行Postgres容器

docker run --rm--namepg-docker-e POSTGRES_PASSWORD=docker -d-p 5432:5432 -v$HOME/docker/volumes/postgres:/var/lib/postgresql/data  postgres

Options:

  • rm: Automatically remove the container and it’s associated file system upon exit. In general, if we are running lots of short term containers, it is good practice to to pass rm flag to the docker run command for automatic cleanup and avoid disk space issues. We can always use the v option (described below) to persist data beyond the lifecycle of a container
  • name: An identifying name for the container. We can choose any name we want. Note that two existing (even if they are stopped) containers cannot have the same name. In order to re-use a name, you would either need pass the rm flag to the docker run command or explicitly remove the container by using the command docker rm [container name].
  • e: Expose environment variable of name POSTGRES_PASSWORD with value docker to the container. This environment variable sets the superuser password for PostgreSQL. We can set POSTGRES_PASSWORD to anything we like. I just choose it to be docker for demonstration. There are additional environment variables you can set. These include POSTGRES_USER and POSTGRES_DB. POSTGRES_USER sets the superuser name. If not provided, the superuser name defaults to postgres.POSTGRES_DB sets the name of the default database to setup. If not provided, it defaults to the value of POSTGRES_USER.
  • d: Launches the container in detached mode or in other words, in the background.
  • p: Bind port 5432 on localhost to port 5432 within the container. This option enables applications running out side of the container to be able to connect to the Postgres server running inside the container.
  • v: Mount $HOME/docker/volumes/postgres on the host machine to the container side volume path /var/lib/postgresql/data created inside the container. This ensures that postgres data persists even after the container is removed.
  • 连接到Postgres

容器启动运行后,从应用程序连接到它与连接到Docker容器外部运行的Postgres实例没有什么不同。例如,要使用psql进行连接,我们可以执行

^{tt6}$

翻译

尚未翻译

安装

通过将collective.fgrcon.pgeasyform添加到构建中来安装它:

[buildout]

...

eggs =
    collective.fgrcon.pgeasyform

然后运行bin/buildout

这个addoon需要collective.easyformpsycopg2

支架

如果您有问题,请告诉我们(使用问题跟踪器或邮件到franz@fgrcon.net)。

许可证

该项目是根据gplv2授权的。

贡献者

变更日志

1.1(2019-06-19)

  • 初次发布。 [fgrcon]

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
使用applets查询的多人java游戏?   java如何基于字符串生成数组   基于java多边形的路径查找   java如何对多列ArrayList排序   java批处理更新从更新中返回了意外的行数(Spring/Hibernate)   java如何使用SeleniumWebDriver列出<tr>标记内的所有<td>   java如何使用SimpleFlatMapper将前缀为CSV的列别名到映射?   java为什么通过eclipse运行/调试TomCat时会出现ClassNotFoundException   java Android滚动视图上次视图未显示内部线性布局   替换字符串中不带空格的字符序列   调用方法时Java Swing GUI冻结   java是否允许/建议重用收集器?   在同步方法中使用java hashmap迭代器时   在java XMLDecoder XMLEncoder中写入XMLdatabase   java I无法在活动的片段中填充recyclerview   java Jitsi在调用过程中播放WAV文件如果可能,与音频混合   java JPA为什么我看到DB中每行有两个实体实例?