Integrate Inputs/PainterPalette.csv for artist metadata and influence links, add db/schema.sql with server/migrate.js, letterbox influence panel thumbnails, and refresh Titian/Pontormo images. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
require('dotenv').config();
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const pool = require('../server/db');
|
|
|
|
function csvEscape(value) {
|
|
const v = value == null ? '' : String(value);
|
|
if (/[",\n\r]/.test(v)) return `"${v.replace(/"/g, '""')}"`;
|
|
return v;
|
|
}
|
|
|
|
async function main() {
|
|
const { rows } = await pool.query(`
|
|
SELECT a.name AS artist, p.title AS painting, p.year
|
|
FROM paintings p
|
|
JOIN artists a ON a.id = p.artist_id
|
|
ORDER BY a.name, p.year NULLS LAST, p.title
|
|
`);
|
|
|
|
const outDir = path.join(__dirname, '..', 'Output');
|
|
fs.mkdirSync(outDir, { recursive: true });
|
|
|
|
const header = 'artist,painting,year';
|
|
const lines = rows.map((r) =>
|
|
[csvEscape(r.artist), csvEscape(r.painting), csvEscape(r.year ?? '')].join(',')
|
|
);
|
|
const file = path.join(outDir, 'paintings.csv');
|
|
fs.writeFileSync(file, `${[header, ...lines].join('\n')}\n`, 'utf8');
|
|
console.log(`Wrote ${rows.length} rows to ${file}`);
|
|
await pool.end();
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error(err);
|
|
process.exit(1);
|
|
});
|