Tag: postgresql

PostgreSQL错误的时间戳没有时区转换时间戳与时区

今天上午我面临以下问题: select '2011-12-30 00:30:00'::timestamp without time zone AT TIME ZONE 'EST5EDT'; 回复我2011-12-30 05:30:00+00女巫是错的。 但接下来的查询如下: select '2011-12-30 00:30:00'::timestamp without time zone AT TIME ZONE 'UTC-5'; select '2011-12-30 00:30:00' AT TIME ZONE 'EST5EDT'; 我看到正确的date2011-12-29 19:30:00 防止你对我的本地时区的问题: SELECT current_setting('TIMEZONE'); current_setting —————– UTC (1 row) 有timestamp without time zone人有答案为什么postgresql转换timestamp without time zone一些怪异的方式,而是带走5小时,而不是增加呢?

耙db:创build抛出“数据库不存在”错误postgresql

我在Debian 7下使用rails 4.1.5和postgresql 9.1,而且我无法在开发环境中创build数据库。 当我跑步 bin/rake db:create 我明白了 home/rs/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:898:in `rescue in connect': FATAL: database "direct-dev" does not exist Run `$ bin/rake db:create db:migrate` to create your database (ActiveRecord::NoDatabaseError) from /home/rs/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect' from … 我正在尝试创build数据库,所以它自然不存在。 不过铁轨应该创build它…这是我的config / database.yml: default: &default adapter: postgresql encoding: unicode pool: 5 development: <<: *default database: direct-dev 这里是postgresql日志的一部分: 2014-09-01 19:30:40 CEST LOG: […]

dynamic(基于列)的时间间隔

如何为NOW添加dynamic(基于列)天数? SELECT NOW() + INTERVAL a.number_of_days "DAYS" AS "The Future Date" FROM a; a.number_of_days是一个整数?

如何删除Postgresql中的回车和新行?

所有, 我再次卡住试图让我的数据在我需要它的格式。我有一个文本字段,看起来像这样。 “deangelo 001 deangelo 名字的本地起源:italain 从美国名称deangelo 意思是:天使的 情感谱•他是所有人欢乐的泉源。 个人诚信•他的美名是他最宝贵的财富。 个性•当你被火鸡包围时,很难用鹰翱翔! 关系•开始缓慢,但与deangelo的关系随着时间而build立。 旅行和休闲•一生中的一次旅行是在他的未来。 职业和金钱•一个天才的孩子,deangelo将需要不断挑战。 生活的机会•欢乐和幸福等待着这个幸运的人。 deangelo的幸运数字:12•38•18•34•29•16 “ Postgresql最好的办法是删除回车和新行? 我已经尝试了几件事情,他们都不想performance出来。 select regexp_replace(field, E'\r\c', ' ', 'g') from mytable WHERE id = 5520805582 SELECT regexp_replace(field, E'[^\(\)\&\/,;\*\:.\>\<[:space:]a-zA-Z0-9-]', ' ') FROM mytable WHERE field~ E'[^\(\)\&\/,;\*\:.\<\>[:space:]a-zA-Z0-9-]' AND id = 5520805582; 在此先感谢,亚当

服务器是否在主机“localhost”(:: 1)上运行,并接受端口5432上的TCP / IP连接?

我正在Django上工作。 我使用PostgreSQL数据库。 完整的错误说: could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? 你有什么主意吗?

Postgresql表中最大(可用)的行数

我意识到,根据Pg文档( http://www.postgresql.org/about/ ),可以在表中存储无限数量的行。 但是,对于可用的行数(如果有的话),“经验法则”是什么? 背景:我想存储1300万个细胞的几十年的日常读数。 可以达到13M *(366 | 365)* 20〜9.5e10或95B行(实际上大约120B行)。 所以,使用表分区,我build立一个主表,然后按年份inheritance表。 这将行分成〜5.2 B每行。 每行有9个SMALLINT,两个INT,所以有26个字节。 除此之外,每行23字节的Pg开销,每行得到49字节。 所以,没有任何PK或任何其他指标的每张表格的重量约为0.25 TB。 对于初学者来说,我只创build了上述数据的一个子集,也就是只有大约25万个单元格。 我必须做一些调整(创build合适的索引等),但是现在的性能真的很糟糕。 此外,每次我需要添加更多的数据,我将不得不放弃钥匙,并重新创build它们。 节约的优点是一旦所有的东西都被加载,它将是一个只读的数据库。 有什么build议么? 任何其他的分区策略?

如何使用SQLAlchemy创buildSQL视图?

一切都在标题中。 有没有“Pythonic”方法(我的意思是,没有“纯SQL”查询)来定义SQL视图与SQLAlchemy? 谢谢你的帮助,

Rails的3.1 – 推向Heroku – 错误安装postgres适配器?

我刚刚升级到Rails 3.1,我试图部署到Heroku的第一个应用程序遇到了与Postgres适配器有关的问题。 我能够把应用程序推到heroku,但是当我尝试迁移数据库时,我得到以下错误: heroku rake db:migrate rake aborted! Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) Tasks: TOP => db:migrate => db:load_config (See full trace by running task with –trace) 当我尝试他们的build议安装我得到: ERROR: Could not find a valid gem 'activerecord-postgresql-adapter' (>= 0) in any repository […]

主机没有pg_hba.conf条目

当我尝试使用DBI进行连接时出现以下错误 DBI connect('database = chaosLRdb; host = 192.168.0.1; port = 5433','postgres',…) 失败:致命:没有pg_hba.conf项为主机“192.168.0.1”,用户“postgres”,数据库“chaosLRdb”,SSLclosures 这是我的pg_hba.conf文件: # "local" is for Unix domain socket connections only local all all md5 # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 host all postgres 127.0.0.1/32 trust host all postgres 192.168.0.1/32 trust host […]

Postgres失败,无法打开关系映射文件“global / pg_filenode.map”

我在我的开发环境中安装postgres时遇到问题,我需要一些帮助来诊断它。 我还没有find解决scheme的运气。 我有安装了自制软件的postgres 9.0.4 我在OS X 10.6.8(Snow Leopard)上运行 我可以启动和停止服务器 $ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start server starting 如果我试图阻止 $ pg_ctl -D /usr/local/var/postgres stop -s -m fast pg_ctl: PID file "/usr/local/var/postgres/postmaster.pid" does not exist Is server running? 好吧,这是缺less $ ls -l /usr/local/var/postgres/ | grep postmaster $ 但它肯定是在运行 $ ps aux | grep postgres pschmitz 303 […]