Optimizing importing json into sqlite with or without drizzle

Hi guys, I have this script running over my 60k row json file and somehow this is really really slow. is there an optimized way for turso?
const jsonData = JSON.parse(data);
const parsedJsonData = citySchema.parse(jsonData);

for (const city of parsedJsonData) {
await db.insert(schema.city).values({
id: city.id,
lon: city.lon,
admin1: city.admin1,
admin2: city.admin2,
lat: city.lat,
country: city.country,
name: city.name,
});
}
const jsonData = JSON.parse(data);
const parsedJsonData = citySchema.parse(jsonData);

for (const city of parsedJsonData) {
await db.insert(schema.city).values({
id: city.id,
lon: city.lon,
admin1: city.admin1,
admin2: city.admin2,
lat: city.lat,
country: city.country,
name: city.name,
});
}
I'm now 15 min into this script and were able to only add 4k lines
3 Replies
Neto
Neto•9mo ago
Drizzle ORM - Insert
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Neto
Neto•9mo ago
You can also run multiple of those in parallel
FleetAdmiralJakob 🗕 🗗 🗙
nice, down to 15 seconds
Want results from more Discord servers?
Add your server