Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
97db46bc
Commit
97db46bc
authored
Jun 29, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(PGSQLInterface): добавил функцию быстрой вставки (на основе COPY)
parent
a5a16445
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
PostgreSQLInterface.cc
extensions/DBServer-PostgreSQL/PostgreSQLInterface.cc
+27
-0
PostgreSQLInterface.h
extensions/DBServer-PostgreSQL/PostgreSQLInterface.h
+3
-0
No files found.
extensions/DBServer-PostgreSQL/PostgreSQLInterface.cc
View file @
97db46bc
...
...
@@ -86,6 +86,33 @@ bool PostgreSQLInterface::close()
return
true
;
}
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
copy
(
const
std
::
string
&
tblname
,
const
std
::
list
<
std
::
string
>&
cols
,
const
std
::
list
<
std
::
list
<
std
::
string
>>&
data
)
{
if
(
!
db
)
return
false
;
try
{
work
w
(
*
(
db
.
get
())
);
tablewriter
t
(
w
,
tblname
,
cols
.
begin
(),
cols
.
end
());
t
.
reserve
(
data
.
size
());
for
(
const
auto
&
d
:
data
)
t
.
push_back
(
d
.
begin
(),
d
.
end
());
t
.
complete
();
w
.
commit
();
return
true
;
}
catch
(
const
std
::
exception
&
e
)
{
//cerr << e.what() << std::endl;
lastE
=
string
(
e
.
what
());
}
return
false
;
}
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
insert
(
const
string
&
q
)
{
if
(
!
db
)
...
...
extensions/DBServer-PostgreSQL/PostgreSQLInterface.h
View file @
97db46bc
...
...
@@ -48,6 +48,9 @@ class PostgreSQLInterface:
virtual
double
insert_id
()
override
;
void
save_inserted_id
(
const
pqxx
::
result
&
res
);
// fast insert: Use COPY..from SDTIN..
virtual
bool
copy
(
const
std
::
string
&
tblname
,
const
std
::
list
<
std
::
string
>&
cols
,
const
std
::
list
<
std
::
list
<
std
::
string
>>&
data
);
virtual
const
std
::
string
error
()
override
;
protected
:
...
...
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