Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
sqlcを利用してsqlに型付けを
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
kamiyam
October 02, 2024
Programming
650
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
sqlcを利用してsqlに型付けを
kamiyam
October 02, 2024
More Decks by kamiyam
See All by kamiyam
useImperativeHandle を迷いながら使った話
kamiyam
0
89
GraphQLで使うデータに TypeScriptで型を定義する
kamiyam
1
650
Other Decks in Programming
See All in Programming
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
250
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
140
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
260
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
140
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
220
FreeBSDでZabbixを動かす
kenkino
0
300
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
190
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
440
App Intentsのビルドプロセスを支える技術
kntkymt
0
390
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
390
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
180
一人だけ、Kiroが静止する日
hideg
0
120
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
340
58k
A designer walks into a library…
pauljervisheath
211
25k
Six Lessons from altMBA
skipperchong
29
4.5k
Google's AI Overviews - The New Search
badams
0
1.6k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
360
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Into the Great Unknown - MozCon
thekraken
41
2.7k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
460
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Odyssey Design
rkendrick25
PRO
2
810
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
430
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
230
Transcript
sqlcΛར༻ͯ͠sqlʹܕ͚Λ kansai.ts #8 2024.10.2 @kamiyam
ࣗݾհ ͔ΈΜ (Twitter@kamiyam) ݩࣗಈंඋ࢜ METEORWORKS Inc. Engineer ϑϩϯτʙ όοΫΤϯυNode.jsશൠ
What is sqlc?
IUUQTTRMDEFW
TRMDHFOFSBUF TRMDZNMΛར༻ͯ͠ίʔυΛੜ͢Δ IUUQTEPDTTRMDEFWFOMBUFTUIPXUPHFOFSBUFIUNM
sqlcࣗମCLIπʔϧͱͯ͠ Πϯετʔϧ͢ΔܗͰར༻͢Δ͜ͱʹͳΔ (MacͳΒbrewͳͲ)
None
SQLϑΝΠϧΛಡΈऔͬͯɺgoίʔυΛੜ͢Δπʔϧ
Goݴޠ?
IUUQTHJUIVCDPNTRMDEFWTRMDHFOUZQFTDSJQU
None
plugin ͱͯ͠ TypeScript͚ SQLϑΝΠϧ͔Βܕ҆શͳίʔυΛੜ͢Δ
None
Supported engines and drivers - PostgreSQL via pg or postgres.
- MySQL via mysql2. - SQLite via sqlite3.
ڥʹsqlcΛΠϯετʔϧ͢ΔͷΛආ͚ DockerΛ͔Β࣮ߦ͢Δํ๏
None
How to use sqlc.
IUUQTHJUIVCDPNTRMDEFWTRMDHFOUZQFTDSJQUCMPC NBJOFYBNQMFTBVUIPSTNZTRMRVFSZTRM
IUUQTEPDTTRMDEFWFOTUBCMFSFGFSFODFRVFSZBOOPUBUJPOTIUNM
%&.0
Tips. PostgreSQL ͷํ͕खް͘αϙʔτͯͦ͠͏ MySQL Ͱ insertޙͷid ͢Β… ϚΠάϨʔγϣϯʹରԠ͍ͯ͠ͳ͍ͷͰ ผͷϥΠϒϥϦΛ͏ඞཁ͕͋Δ
Refs. Compile SQL to type-safe code; catch failures before they
happen. https://sqlc.dev/ generate - Generating code https://docs.sqlc.dev/en/latest/howto/generate.html sqlc-gen-typescript https://github.com/sqlc-dev/sqlc-gen-typescript sqlc-gen-typescriptͰMySQLͰinsertޙͷID͕΄͍͠ https://qiita.com/Yuumillar/items/b1e3ec74eac725834735
sqlc-gen-typescript ͷ࠷৽ίʔυΛϏϧυͯ͠ v0.1.3Ͱར༻Ͱ͖ͳ͍ execlastid Λར༻͢Δ
None
ϩʔΧϧͷίϚϯυͰ͍͚Δ͕ EPDLFSͰ͏·͍͔ͣ͘ʜ
Why use sqlc?
rLBNJZBN lͦΕͧΕͷ03Ϛούʔͷهड़Λ֮͑ΔͷͰ͋Ε 42-Λॻ͍ͨํ͕͍͍ʢ͔͠Εͳ͍ʣz
ͳ͓sqlc(-gen-typescript)Λ͓͏ͱࢥͬͯ ϓϩδΣΫτͷnextϒϥϯνʹೖΕͨཌ
None
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠
Refs. Announcing TypedSQL: Make your raw SQL queries type-safe with
Prisma ORM https://www.prisma.io/blog/announcing-typedsql-make-your-raw-sql- queries-type-safe-with-prisma-orm