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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Marta Buda
May 20, 2015
Programming
200
0
Share
Małe co nieco Sequela
TRUG#37 presentation about one of Ruby gems - Sequel. Slides are in polish.
Marta Buda
May 20, 2015
Other Decks in Programming
See All in Programming
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
140
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
4
450
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
180
Road to RubyKaigi: Play Hard(ware)
makicamel
1
550
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
190
書き換えて学ぶTemporal #fukts
pirosikick
2
350
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
320
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
500
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
240
10 Tips of AWS ~Gen AI on AWS~
licux
5
540
PHPer、Cloudflare に引っ越す
suguruooki
1
140
Featured
See All Featured
Building an army of robots
kneath
306
46k
Designing for Performance
lara
611
70k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
180
Side Projects
sachag
455
43k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
240
How to Think Like a Performance Engineer
csswizardry
28
2.6k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
140
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3k
Discover your Explorer Soul
emna__ayadi
2
1.1k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
70
39k
Statistics for Hackers
jakevdp
799
230k
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 㗂㘊㗌㗨㗆 ❤