Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Małe co nieco Sequela
Search
Marta Buda
May 20, 2015
Programming
0
180
Małe co nieco Sequela
TRUG#37 presentation about one of Ruby gems - Sequel. Slides are in polish.
Marta Buda
May 20, 2015
Tweet
Share
Other Decks in Programming
See All in Programming
1から理解するWeb Push
dora1998
7
1.9k
為你自己學 Python - 冷知識篇
eddie
1
350
AIと私たちの学習の変化を考える - Claude Codeの学習モードを例に
azukiazusa1
11
4.4k
GitHubとGitLabとAWS CodePipelineでCI/CDを組み比べてみた
satoshi256kbyte
4
250
実用的なGOCACHEPROG実装をするために / golang.tokyo #40
mazrean
1
290
testingを眺める
matumoto
1
140
プロパティベーステストによるUIテスト: LLMによるプロパティ定義生成でエッジケースを捉える
tetta_pdnt
0
3.3k
複雑なドメインに挑む.pdf
yukisakai1225
5
1.2k
アセットのコンパイルについて
ojun9
0
130
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
110
Design Foundational Data Engineering Observability
sucitw
3
200
CloudflareのChat Agent Starter Kitで簡単!AIチャットボット構築
syumai
2
510
Featured
See All Featured
Making Projects Easy
brettharned
117
6.4k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.1k
Docker and Python
trallard
46
3.6k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
Raft: Consensus for Rubyists
vanstee
140
7.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Optimizing for Happiness
mojombo
379
70k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
920
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
Transcript
Małe co nieco Sequela .BSUB#VEB 536(
Sequel? • Narzędzie do korzystania z relacyjnych baz danych. •
Obsługuje: ADO, Amalgalite, CUBRID, DataObjects, IBM_DB, JDBC, MySQL, Mysql2, ODBC, Oracle, PostgreSQL, SQLAnywhere, SQLite3, Swift oraz TinyTDS. • https://github.com/jeremyevans/sequel • http://sequel.jeremyevans.net
Historia • 1. wersja: 4. marca 2007. • Do tej
pory 168 wydań. • Obecnie 4.22.0 najnowsza. • Na początku każdego miesiąca uaktualnienia. • TL;DR Rozwija się regularnie od ponad 8 lat.
Od czego zacząć? • Od połączenia z bazą danych. •
Można nawiązać więcej niż jedno połączenie. • Obiekt Sequel::Database • Więcej na: http://sequel.jeremyevans.net/rdoc/files/ doc/opening_databases_rdoc.html
Migracje • Podobne do ActiveRecord, zmieniają schemat bazy danych. Dodawanie
tabel, zmiany kolumn, indeksy, itd. itp. • Sequel Migrator odpalany w terminalu: sequel -m path/to/migrations postgres://host/database • Rollback do początku: sequel -m path/to/migrations -M 0 postgres://host/database
Sequel::Dataset • Obiekt reprezentujący zapytania SQL do bazy. • Może
zawierać całą tabele DB[:table_name] • lub wybrany zbiór rekordów DB.from(“table_name”).where(:column => “value”) .order(:another_column).all
Sequel::Model class Example < Sequel::Model(FIRST_DB[:examples]) end class Other < Sequel::Model(SECOND_DB[:others])
end • Model powiązany ze swoim Dataset. • Walidacja: def validate super errors.add(:column, ‘cannot be empty’) if !column || column.empty? end
Pluginy • Rozszerzają możliwości Sequela. • Przykłady: - validation_helpers -
timestamps • Sequel::Model.plugin :timestamps
Testy, testy • DatabaseCleaner: DatabaseCleaner[:sequel, {:connection => Sequel.connect(uri)}] • Sequel.mock
Sequel.mock(:fetch => [ {:column => “value”, :another => “other” }, { :column => “blabla”, :another => “other” } ]) }
Pytania? Uwagi? Spostrzeżenia?
Dziękuję Thank you 㗂㘊㗌㗨㗆 ❤