Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
import-excel-to-postgresql
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bovorn Siriampairat
import-excel-to-postgresql
Commits
e1ef3ad6
Commit
e1ef3ad6
authored
Jul 18, 2023
by
bovornsiriampairat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Truncate Function
parent
b1d40966
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
import_multi_row.js
import_multi_row.js
+11
-6
No files found.
import_multi_row.js
View file @
e1ef3ad6
...
...
@@ -60,6 +60,17 @@ xml2js.parseString(xmlString, async (err, result) => {
const
startTime
=
new
Date
();
try
{
// Connect to the PostgreSQL database
const
client
=
await
pool
.
connect
();
const
tableName
=
'tpytran1'
;
// Specify the table name
// Truncate the table and restart identity
const
truncateQuery
=
`TRUNCATE TABLE
${
tableName
}
RESTART IDENTITY`
;
await
client
.
query
(
truncateQuery
);
// Insert the data into the PostgreSQL database
for
(
let
i
=
1
;
i
<
data
.
length
;
i
++
)
{
const
row
=
data
[
i
];
const
mappedEmployee
=
{};
...
...
@@ -91,12 +102,6 @@ xml2js.parseString(xmlString, async (err, result) => {
console
.
log
(
`Progress:
${
progress
.
toFixed
(
2
)}
%`
);
}
try
{
// Connect to the PostgreSQL database
const
client
=
await
pool
.
connect
();
// Insert the data into the PostgreSQL database
const
tableName
=
'tpytran1'
;
// Specify the table name
for
(
const
employee
of
jsonData
.
employee
)
{
const
{
employeeid
,
formulaid
}
=
employee
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment