Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Pool = require('pg').Pool;
- const csv = require('csv-parser');
- const fs = require('fs');
- const pool = new Pool({
- user: '***',
- host: '***',
- database: '***',
- password: '***',
- port: 5432
- });
- fs.createReadStream('/home/***/fullAddress.csv')
- .pipe(csv())
- .on('data', (row) => {
- const url = "http://***/"+row.street_code+"/"+row.id+"/***";
- const provider="***";
- pool.query(
- 'INSERT INTO public.data (address_id, url, provider) VALUES ($1, $2, $3)',
- [row.address_id, url, provider],
- (error, results) => {
- if (error) {
- throw error
- }
- }
- )
- })
- .on('end', () => {
- console.log('CSV file successfully processed');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement