postgresql

PostgreSQL query output as a excel file

人走茶凉 提交于 2020-12-26 09:40:08
问题 I want to save the result of a psql query as an Excel file. ie, I have a table named company with 5 column. I want to execute the query, SELECT column_1, column_2, FROM company; And I just want to save the result of this query as a Excel file. Is it possible in PostgreSQL? If yes then please explain it. Thank you...... 回答1: You could use csv to save your data and open/work with them in Excel. Syntax would be something like: Copy (SELECT column_1, column_2, FROM company; ) To '/tmp/test.csv'

PostgreSQL query output as a excel file

岁酱吖の 提交于 2020-12-26 09:39:52
问题 I want to save the result of a psql query as an Excel file. ie, I have a table named company with 5 column. I want to execute the query, SELECT column_1, column_2, FROM company; And I just want to save the result of this query as a Excel file. Is it possible in PostgreSQL? If yes then please explain it. Thank you...... 回答1: You could use csv to save your data and open/work with them in Excel. Syntax would be something like: Copy (SELECT column_1, column_2, FROM company; ) To '/tmp/test.csv'

Importing shapefiles in postgresql in linux using pgadmin 4

孤人 提交于 2020-12-26 08:23:06
问题 I am new to postGIS, I was following this tutorial. I can't get past the installation part because the instructions are outdated. I got stuck when it says return to the Dashboard, and click on the Import shapefiles link in the PostGIS section. I am using pgadmin 4 and I am unable to find the postGIS section there. 回答1: If you're simply trying to import shapefiles into PostgreSQL, you might wanna take a look at shp2pgsql. Data sample: TM_WORLD_BORDERS_SIMPL-0.3.zip After unpacking your zip

Prevent SQL Injection with Nodejs and Postgres

好久不见. 提交于 2020-12-26 08:17:15
问题 I'm developing a backend to interact with a PostgreSQL database and am looking for some help preventing SQL injection. I understand the concept of SQL injection, and have found some examples online in preventing those attacks, but not sure if prevention techniques differ between SQL providers. This is the function I use to query data: var pg = require("pg"); var client = new pg.Client(connectionString); client.connect(); module.exports = async function newQuery(query) { var result = await

Prevent SQL Injection with Nodejs and Postgres

。_饼干妹妹 提交于 2020-12-26 08:17:13
问题 I'm developing a backend to interact with a PostgreSQL database and am looking for some help preventing SQL injection. I understand the concept of SQL injection, and have found some examples online in preventing those attacks, but not sure if prevention techniques differ between SQL providers. This is the function I use to query data: var pg = require("pg"); var client = new pg.Client(connectionString); client.connect(); module.exports = async function newQuery(query) { var result = await

Execute SQL functions with Laravel 5

放肆的年华 提交于 2020-12-26 07:16:51
问题 I have SQL functions stored on my database. However, I can not call them. $nb = DB::select('SELECT nb_seances_archivees()'); The result is : array:1 [▼ 0 => {#186 ▼ +"nb_seances_archivees": 0 } ] But the desired result is just 0 . Thank's for help ! 回答1: By default DB::select return an array of objects, you can use collections to get the first result: $nb = collect(DB::select('SELECT nb_seances_archivees() AS nb'))->first()->nb; Or directly access the first object in the array: $nb = DB:

postgresql数据库 TimescaleDB 定时压缩超表 删除超表(块)

自古美人都是妖i 提交于 2020-12-25 10:01:07
** postgresql数据库 TimescaleDB 定时压缩超表 删除超表(块) ** 在工作中 使用postgresql数据库 TimescaleDB 时序库进行存储实时数据,采集的数据量过大,提供的内存不足,因此考虑如何保存数据 TimescaleDB数据库中的超级表 TimescaleDB数据库自身带着函数就可以实现 ** TimescaleDB数据库所携带函数 一 .压缩 SELECT compress_chunk() ** 为了尽量不丢失数据,避免删除数据 我首先考虑把数据压缩,用他自带的函数 SELECT compress_chunk() 1查询时间 show_chunks() CREATE OR REPLACE FUNCTION "hrmw" . "show_chunks" ( "hypertable" regclass = NULL ::regclass , "older_than" any = NULL ::unknown , "newer_than" any = NULL ::unknown ) RETURNS SETOF "pg_catalog" . "regclass" AS '$libdir/timescaledb-1.7.1' , 'ts_chunk_show_chunks' LANGUAGE c STABLE COST 1 ROWS 1000

SQLAlchemy no password supplied error

时间秒杀一切 提交于 2020-12-24 02:42:44
问题 This is probably a silly error but I cannot seem to find a satisfying solution. When running db.create_all() , I got the following error. sqlalchemy.exc.OperationalError: (OperationalError) fe_sendauth: no password supplied None None My database link is set as 'postgresql://localhost/db_name' This worked fine on my Mac and Heroku, but is not OK on ubuntu (digitalocean). Any ideas what I might be doing wrong? 回答1: You probably just need to remove "localhost" from your connection string:

SQLAlchemy no password supplied error

别等时光非礼了梦想. 提交于 2020-12-24 02:40:05
问题 This is probably a silly error but I cannot seem to find a satisfying solution. When running db.create_all() , I got the following error. sqlalchemy.exc.OperationalError: (OperationalError) fe_sendauth: no password supplied None None My database link is set as 'postgresql://localhost/db_name' This worked fine on my Mac and Heroku, but is not OK on ubuntu (digitalocean). Any ideas what I might be doing wrong? 回答1: You probably just need to remove "localhost" from your connection string:

Odoo14介绍1:Ubuntu18.04通过源码安装Odoo14

可紊 提交于 2020-12-24 02:28:58
本系列背景介绍 Odoo 是一个基于Python语言构建的开源软件,面向企业应用的CRM,ERP等领域,其目标是对标SAP,Oracle等大型软件提供商,但却通过仅仅一个平台满足企业所有管理的业务需求。 本系列文章针对Odoo 14版,从系统安装,开发环境配置,代码结构,主要功能升级,源码赏析,Anodoo对Odoo的关键扩展等角度,预先给大家介绍即将在2020年发布的这一最新版本。 本篇概述 Odoo14的安装和历史版本差不多,同样也包括安装文件,源码,Docker等多种形式,本文则通过源码方式在Ubuntu 18.04上安装Odoo 14. Postgresql数据库准备 在PostgreSQL官网,或者通过apt命令安装数据库。 https://www.postgresql.org/ https://www.postgresql.org/download/linux/ubuntu/ sudo apt update sudo apt install postgresql postgresql-contrib 由于是开发环境,使用当前用户,以及使用postgresql的createdb命令增加数据库: Created odoo14 通过源码安装 由于Anodoo在Odoo上进行源码级别的扩展,所以本文优先演示源码安装模式。 在 http://nightly.odoo.com/