postgresql

Postgres Timestamp

此生再无相见时 提交于 2021-02-06 21:38:31
问题 We are having a debate about the best way to store a timestamp in postgres. Currently all time stamps are stored as +00 and we have a timezone associated with each client. We look up the timezone and convert the time that something happened which increases complexity as we need to do more joins and a more complex query. Another method is connecting to Postgres and setting the timezone of the connection and it changes all the times to be that timezone. My problem with this is that in ANZ there

Sortable UUIDs and overriding ActiveRecord::Base

若如初见. 提交于 2021-02-06 20:00:45
问题 I'm wanting to use UUIDs in an app I'm building and am running into a bit of a problem. Due to UUIDs (v4) not being sortable because they're randomly generated, I'm trying to override ActiveRecord::Base#first, but Rails isn't too pleased with that. It yells at me saying ArgumentError: You tried to define a scope named "first" on the model "Item", but Active Record already defined a class method with the same name. Do I have to use a different method if I want to sort and have it sort

Sortable UUIDs and overriding ActiveRecord::Base

非 Y 不嫁゛ 提交于 2021-02-06 20:00:26
问题 I'm wanting to use UUIDs in an app I'm building and am running into a bit of a problem. Due to UUIDs (v4) not being sortable because they're randomly generated, I'm trying to override ActiveRecord::Base#first, but Rails isn't too pleased with that. It yells at me saying ArgumentError: You tried to define a scope named "first" on the model "Item", but Active Record already defined a class method with the same name. Do I have to use a different method if I want to sort and have it sort

Best performance in sampling repeated value from a grouped column

人走茶凉 提交于 2021-02-06 15:15:44
问题 This question is about the functionality of first_value(), using another function or workaround. It is also about "little gain in performance" in big tables. To use eg. max() in the explained context below, demands spurious comparisons. Even if fast, it imposes some additional cost. This typical query SELECT x, y, count(*) as n FROM t GROUP BY x, y; needs to repeat all columns in GROUP BY to return more than one column. A syntactic sugar to do this, is to use positional references: SELECT x,

Array of composite type as stored procedure input passed by C# Npgsql

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-06 14:00:11
问题 I've read several questions and topics related to the issue but none of them actually helped me to solve my problem and none of them actually were related to C#. And here is the actual problem: I have a Postgre composite type: CREATE TYPE law_relation_update_model AS ( from_celex character varying, from_article character varying, to_celex character varying, to_article character varying, link_ids integer[], to_doc_par_id integer ); And I have a stored procedure that is meant to accept an array

Array of composite type as stored procedure input passed by C# Npgsql

帅比萌擦擦* 提交于 2021-02-06 13:59:54
问题 I've read several questions and topics related to the issue but none of them actually helped me to solve my problem and none of them actually were related to C#. And here is the actual problem: I have a Postgre composite type: CREATE TYPE law_relation_update_model AS ( from_celex character varying, from_article character varying, to_celex character varying, to_article character varying, link_ids integer[], to_doc_par_id integer ); And I have a stored procedure that is meant to accept an array

Postgresql creating database

女生的网名这么多〃 提交于 2021-02-06 10:12:32
问题 Well I installed the latest postgreql database on my Windows 7. Now I'm trying to create a database via the psql.exe command line When I open it, it says psql: FATAL: database "Jansu" does not exist So I read somewhere, that when no database is specified, it tried to find database with my username or something. Anyways..how do i create a new database, when I can't access the commandline. 回答1: Read psql syntax. You can specify database, user and other parameters. If it's a new installation,

missing libgeos_c.so on OSX

我只是一个虾纸丫 提交于 2021-02-06 10:07:02
问题 I am trying to install Postgis in order to use GeoDjango on OSX. For this, I first uninstalled postgres completely, then I installed everything following the GeoDjango documentation: https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#homebrew I did the following: brew update brew upgrade brew install postgresql brew install postgis brew install gdal brew install libgeoip When I run my Django project, I get the following error: OSError at / dlopen(/usr/local/lib/libgeos_c.so, 6):

missing libgeos_c.so on OSX

走远了吗. 提交于 2021-02-06 10:03:52
问题 I am trying to install Postgis in order to use GeoDjango on OSX. For this, I first uninstalled postgres completely, then I installed everything following the GeoDjango documentation: https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#homebrew I did the following: brew update brew upgrade brew install postgresql brew install postgis brew install gdal brew install libgeoip When I run my Django project, I get the following error: OSError at / dlopen(/usr/local/lib/libgeos_c.so, 6):

Python——Scrapy爬取链家网站所有房源信息

浪子不回头ぞ 提交于 2021-02-06 09:49:57
用scrapy爬取链家全国以上房源分类的信息: 路径: items.py # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See documentation in: # https://doc.scrapy.org/en/latest/topics/items.html import scrapy class LianItem(scrapy.Item): # define the fields for your item here like: # name = scrapy.Field() pass class ErShouFangItem(scrapy.Item): # 省份 province = scrapy.Field() # 城市 city = scrapy.Field() # 总价 total_price = scrapy.Field() # 单价 single_price = scrapy.Field() # 楼层 room_info = scrapy.Field() # 住宅位置 region = scrapy.Field() # 房屋朝向及装修情况 direction = scrapy.Field() # 建筑面积 area = scrapy.Field() #