postgresql

How use `unaccent` with full text search in django 1.10?

点点圈 提交于 2021-01-20 16:16:17
问题 We are working on a project and we are using Django 1.10a1 , we're using django full text search with PostgreSQL but we need to use unaccent. So, I have this code: search = 'Car' query_set = Article.objects.annotate( search=SearchVector( 'content', 'name' ) ).filter( search__unaccent=search ) When we tried adding unaccent word after search the query doesn't work. How can we get django full text search to work with postgress unaccent? 回答1: Install the unaccent extension into your database:

Sqlalchemy duplicated WHERE clause to FROM

夙愿已清 提交于 2021-01-20 13:33:21
问题 I wrote raw query to psql and it's work fine but when i wrote this in sqlalchemy my WHERE clause duplicated to FROM clause. select id from T1 where arr && array(select l.id from T1 as l where l.box && box '((0,0),(50,50))'); In this query i fetch all id from T1 where array with ints intersects with results from subquery. class T1(): arr = Column(ARRAY(Integer)) ... class T2(): box = Column(Box) # my geometry type ... 1 verison: layers_q = select([T2.id]).where(T2.box.op('&&')(box)) # try find

如何把 Django 项目部署到服务器?

China☆狼群 提交于 2021-01-20 10:52:36
Django 官网截图 Django 是什么? Django 是基于 Python 开发的一款开源的 Web 应用框架。Django框架不但提供了完善的代码目录结构,而且使用了 Model, View, 和Template的结构,使得代码在开发过程中很容易被规范起来。其中Django Admin提供了开箱即用的后台管理系统而深得众多Python开发者和初创公司喜爱。 21云盒提供了极简单的 Django 部署方法,你可以在21云盒子上通过以 Python 环境进行部署。 如何部署? 注册成为 21云盒子会员 创建一个 PostgreSQL数据库 Fork django示例 在21云盒子上创建一个 云服务 , 并允许21云盒子访问你的代码库 配置以下设定 环境 PYTHON 3.7 构建命令 : ./build.sh 启动命令 : gunicorn hello.wsgi:application 点 进阶配置 进行环境变量配置: KEY VALUE DJANGO_DB_URL 在第一步创建云数据库里中点 数据库URL 获取 DJANGO_ALLOWED_HOSTS <服务名>.21yunbox.com,127.0.0.1 更多Django相关的配置可以参考 官方文档 。 在本示例中, DJANGO_DEBUG=True 只作演示。真实上线时可以在环境变量中把 DJANGO_DEBUG

sqlalchemy filter children in query, but not parent

爷,独闯天下 提交于 2021-01-20 07:27:50
问题 I have a query which returns a User object. User s have a number of Post s which they have made. When I perform a query, I want to filter the posts found in User.post based on a specific time. For example, to return only the posts within 1 day of a given timestamp. class User(base): __tablename__ = 'User' class Post(base): __tablename__ = 'Post' user_id = Column(Integer, ForeignKey('User.uid')) user = relationship(User, backref=backref('post') time = Column(DateTime, default=func.current

Dead Tuples without updates/deletes

一世执手 提交于 2021-01-20 06:45:51
问题 Is it possible? I have a table with fast growing dead tuples, but I can't see any update or delete to the table during the day, just inserts and selects. Autovacuum runs each 10 min, the n_dead_tup goes almost to zero and start growing again. There is one delete at this table, for purging rows with date 15 days ago, running only once per day (triple-checked that is done just once per day). In the rest of the day, only inserts and selects run on this table. 回答1: A failed attempt to insert data

Redis内存碎片清理

耗尽温柔 提交于 2021-01-20 00:05:09
当Redis中清理了大量的Key之后原先Redis申请的内存(used_memory_rss)将继续持有而不会释放,此时查看内存信息将会看到存在大量的内存碎片。那么,Redis的内存碎片可以清理么,该如何清理呢? 翻看了Redis的相关资料发现,Redis4版本之后开始支持内存碎片的清理,于是进行了一次测试,内容如下: 1. 搭建Redis 搭建一个Redis,版本为4.0.14.搭建步骤参考历史博文或微信公众号,步骤相对简单,没有太多幺蛾子,很快便可以搭建成功。 2. 插入一堆Key,使其内存占用很大 可以批量写一个循环,插入大量key。 3. 删除90%以上的key 循环删除key或在创建key时设置过期时间,待key删除或过期之后,可以查看内存的情况。 127 .0 .0 .1 :6379 > info memory # Memory used_memory :137040696 used_memory_human :130.69M used_memory_rss :11705876480 used_memory_rss_human :10.90G used_memory_peak :12091169848 used_memory_peak_human :11.26G used_memory_peak_perc :1.13 % used_memory_overhead

How to return the result of a postgresql function in c#? Console output empty

大憨熊 提交于 2021-01-19 22:27:32
问题 I have the problem that i have a function in postgresql that calculates two integer and should return the result to the c# (npgsql) conosle and i don't know where my mistake is, because the debugger doesn't say anything to me which is helpful. so first of all the code of c# and of the function. ... cmd.Parameters["x"].Value = 20; cmd.Parameters["y"].Value = 22; connection.Open(); if (connection.State == System.Data.ConnectionState.Open) { //Console.WriteLine(cmd.Parameters["x"].Value);

How to return the result of a postgresql function in c#? Console output empty

不羁的心 提交于 2021-01-19 22:27:15
问题 I have the problem that i have a function in postgresql that calculates two integer and should return the result to the c# (npgsql) conosle and i don't know where my mistake is, because the debugger doesn't say anything to me which is helpful. so first of all the code of c# and of the function. ... cmd.Parameters["x"].Value = 20; cmd.Parameters["y"].Value = 22; connection.Open(); if (connection.State == System.Data.ConnectionState.Open) { //Console.WriteLine(cmd.Parameters["x"].Value);

How to abort JDBC Postgresql CopyManager copying?

被刻印的时光 ゝ 提交于 2021-01-19 06:18:07
问题 Is there a way to cancel the copying process started by calling copyIn() method in a separate thread? Say, I have a list of csv-files which I need to copy from, getting maximum of database server power. So I create n-threads-connections for n-files, but I cannot find a way to abort a single operation if, for example, a wrong file has been chosen. Killing threads does not work - COPY just keeps running. The FutureTask<> class is used to create the threads, so there is a list of them - one for

2020年MongoDB中文社区年终线上大会全纪录【附PPT及视频回放】

风流意气都作罢 提交于 2021-01-18 19:37:51
2021年1月8日,MongoDB中文社区联合MongoDB官方、锦木信息、Tapdata和华为开展2020年MongoDB中文社区年终大会。 (文末附本次大会PPT资料包) 点击下方链接 即可观看线上会议回放 http://www.itdks.com/Home/Act/apply?id=5533 大会要点回顾 会议开场由社区常委会委员、北京分会主席李丹给大家介绍社区的基本情况,MongoDB中文社区是由技术大会、技术培训、技术问答、原创博客、文档翻译和线上活动板块组成,是专注于MongoDB的技术交流平台。 MongoDB究竟是一个怎样的数据库? 话不多说,MongoDB究竟是一个怎样的数据库? MongoDB中文社区委员及 WiredTiger存储引擎专栏作者郭远威为我们进行整体解读: 在云数据库和NewSQL时代,该有的的核心特性MongoDB早就有了, 而且更好用! 将集群中的分片部署成复制集,实现故障自动恢复和高可用性。 原生分布式架构,通过分片Shard实现水平弹性伸缩。 3.6的版本以后MongoDB就向ACID 4个特性的事务看齐了,所以MongoDB不仅适用于分布式数据库场景,也支持传统关系型数据库应用场景。 MongoDB多种“读参考”模式,实现灵活的读写分离。 MongoDB模式自由,类JSON格式存储(最接近真实对象模型),对开发者友好。