sequel

How do I pull heroku data into a local SQLite3 database? Running into problems

痞子三分冷 提交于 2019-12-10 13:08:14
问题 I'm trying to make a local backup of the data from my Rails app, which is deployed to Heroku, and running into problems. I followed the instructions here: http://docs.heroku.com/taps and installed Taps. I get two types of errors. I created a SQLite db locally and tried pulling data with this command: (sudo) heroku db:pull sqlite://Users/username/folder/testbackup.db or (sudo) heroku db:pull sqlite://username:password@localhost/Users/username/folder/testbackup.db but either way I get this:

How to call ActiveRecord validators as instance methods (ala Sequel)?

℡╲_俬逩灬. 提交于 2019-12-07 16:12:26
问题 I've got a model that needs different validators depending on its current state. How should I go about calling ActiveRecord validators per instance? I'd like to reuse as much plumbing as possible, but I'm not sure how to continue. class Order < ActiveRecord::Base attr_accessible :state validate :state_specific_validations def state_specific_validations if :paid == self.state # Warning: here be Unicorns... # Wishful thinking... validate_presence_of :paid_at validate_associated :purchaser #

postgres encoding error in sidekiq app

不羁岁月 提交于 2019-12-07 08:39:00
问题 I am working on an application where a ruby sidekiq process calls a 3rd party and parses the data into a database. I am using sequel ad my orm. I am getting some weird characters back in the results, for example: "Tweets en Ingl\xE9s y en Espa\xF1ol" When this gets attempted to save to postgres, the following error happens: Sequel::DatabaseError: PG::CharacterNotInRepertoire: ERROR: invalid byte sequence for encoding "UTF8": 0xe9 0x73 0x20 The weird thing is that the string thinks it is UTF-8

【零基础】PostgreSQL从入门到精通

半世苍凉 提交于 2019-12-07 08:16:59
基本了解: PostgreSQL :是以加州大学伯克利分校计算机系开发的 POSTGRES,现在已经更名为PostgreSQL,版本 4.2为基础的对象关系型数据库管理系统(ORDBMS)。PostgreSQL支持大部分 SQL标准并且提供了许多其他现代特性:复杂查询、外键、触发器、视图、事务完整性、MVCC。同样,PostgreSQL 可以用许多方法扩展,比如, 通过增加新的数据类型、函数、操作符、聚集函数、索引。免费使用、修改、和分发 PostgreSQL,不管是私用、商用、还是学术研究使用。 特点与优势: PostgreSQL 是一个自由的对象-关系数据库服务器(数据库管理系统),它在灵活的 BSD-风格许可证下发行。它提供了相对其他开放源代码数据库系统(比如 MySQL 和 Firebird),和专有系统(比如 Oracle、Sybase、IBM 的 DB2 和 Microsoft SQL Server)之外的另一种选择。 PostgreSQL 不寻常的名字导致一些读者停下来尝试拼读它,特别是那些把SQL拼读为"sequel"的人。PostgreSQL 开发者把它拼读为 "post-gress-Q-L"。它也经常被简略念为 "postgres"。 事实上, PostgreSQL 的特性覆盖了 SQL-2/SQL-92 和 SQL-3/SQL-99,首先

ruby sequel gem - how to query arrays with the pg_array extension

烈酒焚心 提交于 2019-12-07 03:14:56
问题 I am using the pg_array extension and sequel version 4.1.1. I have added the extension like this: Sequel::Database.extension :pg_array I have created a column like this: alter_table :emails do add_column :references, "text[]", null: true end I can load and retrieve arrays into a postgress array column, just like working with normal arrays. What is not clear from the above link is how do I execute a query based on the values in this array column. For example, if one row in the emails table

How do I define an ARRAY column in a Sequel Postgresql migration?

戏子无情 提交于 2019-12-07 00:08:15
问题 I am creating a Sequel migration to create a new table in my PostgreSQL database. I want to define a String array column, which PostgreSQL supports. My migration looks like this: create_table :venues do primary_key :id String :reference , :null => false String :name , :null => false String :description , :null => false String[] :type , :null => false DateTime :created_at , :null => false DateTime :updated_at , :null => false end How can I define something like text[] in my migration? 回答1: You

How to call ActiveRecord validators as instance methods (ala Sequel)?

邮差的信 提交于 2019-12-06 03:52:11
I've got a model that needs different validators depending on its current state. How should I go about calling ActiveRecord validators per instance? I'd like to reuse as much plumbing as possible, but I'm not sure how to continue. class Order < ActiveRecord::Base attr_accessible :state validate :state_specific_validations def state_specific_validations if :paid == self.state # Warning: here be Unicorns... # Wishful thinking... validate_presence_of :paid_at validate_associated :purchaser # Hopeful. What are the validators called internally in Rails? errors << PresenceValidator.new(self, :paid

Sequel (Ruby), how to increment and use a DB counter in a safe way?

为君一笑 提交于 2019-12-05 14:17:05
I found 4 "proper" ways to do this: In the cheat sheet for ActiveRecord users substitutes for ActiveRecord's increment and increment_counter are supposed to be album.values[:column] -= 1 # or += 1 for increment and album.update(:counter_name=>Sequel.+(:counter_name, 1)) In a SO solution update_sql is suggested for the same effect s[:query_volume].update_sql(:queries => Sequel.expr(3) + :queries) In a random thread I found this one dataset.update_sql(:exp => 'exp + 10'.lit) In the Sequels API docs for update I found this solution http://sequel.jeremyevans.net/rdoc/classes/Sequel/Dataset.html

postgres encoding error in sidekiq app

白昼怎懂夜的黑 提交于 2019-12-05 14:13:10
I am working on an application where a ruby sidekiq process calls a 3rd party and parses the data into a database. I am using sequel ad my orm. I am getting some weird characters back in the results, for example: "Tweets en Ingl\xE9s y en Espa\xF1ol" When this gets attempted to save to postgres, the following error happens: Sequel::DatabaseError: PG::CharacterNotInRepertoire: ERROR: invalid byte sequence for encoding "UTF8": 0xe9 0x73 0x20 The weird thing is that the string thinks it is UTF-8, if I check the encoding name, it says: name.encoding.name #UTF-8 What can I do to ensure that the

ruby sequel gem - how to query arrays with the pg_array extension

一曲冷凌霜 提交于 2019-12-05 10:59:30
I am using the pg_array extension and sequel version 4.1.1. I have added the extension like this: Sequel::Database.extension :pg_array I have created a column like this: alter_table :emails do add_column :references, "text[]", null: true end I can load and retrieve arrays into a postgress array column, just like working with normal arrays. What is not clear from the above link is how do I execute a query based on the values in this array column. For example, if one row in the emails table contained these values in the references column: references ----------------------------------------------