Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
P
pg-batch-insert-test
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Clownce Deng
pg-batch-insert-test
Commits
d0b6f4f8
Commit
d0b6f4f8
authored
May 20, 2020
by
Clownce Deng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*) 代码优化;
parent
6e886e10
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
config.js
src/config.js
+2
-2
pgBatchCopy.js
src/pgBatchCopy.js
+2
-2
pgBatchInsert.js
src/pgBatchInsert.js
+2
-2
No files found.
src/config.js
View file @
d0b6f4f8
...
...
@@ -9,7 +9,7 @@ module.exports = {
// 数据库配置
database_conf
:
{
database_type
:
"pg"
,
database_host
:
"1
27.0.0.1
:5432"
,
database_host
:
"1
92.168.2.103
:5432"
,
database_name
:
"TOPMES6_TEST_V6"
,
database_user
:
"toplinker"
,
database_pwd
:
"TopLinker0510"
,
...
...
@@ -18,5 +18,5 @@ module.exports = {
// TopJS位置
topjs_path
:
"D:/Programs/TopJS/3.3.1/bin/topjs3.exe"
,
// 工作目录
work_path
:
"
F:/workspace/pg_batch_inser
t"
work_path
:
"
D:/pgtes
t"
};
\ No newline at end of file
src/pgBatchCopy.js
View file @
d0b6f4f8
...
...
@@ -41,7 +41,7 @@ try {
var
query
=
DB
.
query
(
LOCAL_DB_CONN
);
var
beforeTime
=
moment
();
query
.
begin
();
// COPY服务端寻找文件,\COPY客户端寻找文件
// COPY服务端寻找文件,\COPY客户端寻找文件
(注意:\COPY只能在SQL Shell中执行,它是变相调用COPY FROM STDIN)
var
sql
=
"COPY oee_machine_log_v2 (workcenter_id,log_time,log_type,lot_no,partnumber,subpart,lot_serial,station,state,"
+
"programe_name,daq_time,analysis_flag,log_data) FROM '{0}/data{1}.csv' delimiter ',' csv header"
;
sql
=
_
.
format
(
sql
,
config
.
work_path
,
wid
);
...
...
@@ -105,7 +105,7 @@ function randomBuildLogFile(workcenter_id, row_count) {
function
randomBuildMapData
()
{
var
retMap
=
{};
for
(
var
count
=
1
;
count
<=
10
0
;
count
++
)
{
for
(
var
count
=
1
;
count
<=
0
;
count
++
)
{
retMap
[
"test_key_"
+
count
]
=
"test_value_"
+
count
;
}
var
retStr
;
...
...
src/pgBatchInsert.js
View file @
d0b6f4f8
...
...
@@ -41,8 +41,8 @@ try {
// 批量插入数据到数据库
console
.
info
(
"start to batchInsert data..."
);
var
query
=
DB
.
query
(
LOCAL_DB_CONN
);
var
beforeTime
=
moment
();
query
.
begin
();
var
beforeTime
=
moment
();
query
.
batchInsert
(
"oee_machine_log_v2"
,
_
.
keys
(
logDataList
[
0
]),
logDataList
);
if
(
query
.
lastError
().
isValid
())
{
query
.
rollback
();
...
...
@@ -84,7 +84,7 @@ function randomBuildLogList(workcenter_id, row_count) {
function
randomBuildMapData
()
{
var
retMap
=
{};
for
(
var
count
=
1
;
count
<=
10
0
;
count
++
)
{
for
(
var
count
=
1
;
count
<=
0
;
count
++
)
{
retMap
[
"test_key_"
+
count
]
=
"test_value_"
+
count
;
}
return
retMap
;
...
...
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