Copy the layer_styles table from one database to another? Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Write spatial operations to PostGIS from QGIS or ArcGISWhy does Ogr2Ogr Postgres import fail?Copy a spatial table from one PostGIS database to another PostGIS databaseCan't see Postgis layers added to QGISCopy tables from one server to another in PostgreSQLconnecting Arc 10.3 to a PostGIS database “the coordinate system identifier is invalid”Issues creating ArcSDE sde_logfile for certain users (username begins with a numeral)Importing a CSV with EWKB field into Postgrespostgis raster to postgres databaseCopying tables results in duplication of some tables, feature classes and relationship classes
What do you call a plan that's an alternative plan in case your initial plan fails?
How does modal jazz use chord progressions?
Can smartphones with the same camera sensor have different image quality?
Fishing simulator
Large external storage stops working after being connected for a long time
What LEGO pieces have "real-world" functionality?
Why is there no army of Iron-Mans in the MCU?
Why did AF447 never return to normal law?
Why can't wing-mounted spoilers be used to steepen approaches?
Qt Number Generator v2
Why does this iterative way of solving of equation work?
Stop battery usage [Ubuntu 18]
Am I ethically obligated to go into work on an off day if the reason is sudden?
Writing Thesis: Copying from published papers
Extraordinarily Forgoes Anthem
Why is superheterodyning better than direct conversion?
Simulating Exploding Dice
How to market an anarchic city as a tourism spot to people living in civilized areas?
Is above average number of years spent on PhD considered a red flag in future academia or industry positions?
Split bolt connection. Wire direction
What was the last x86 CPU that did not have the x87 floating-point unit built in?
If A makes B more likely then B makes A more likely"
Aligning matrix of nodes with grid
Dead sea in the midrashim
Copy the layer_styles table from one database to another?
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Write spatial operations to PostGIS from QGIS or ArcGISWhy does Ogr2Ogr Postgres import fail?Copy a spatial table from one PostGIS database to another PostGIS databaseCan't see Postgis layers added to QGISCopy tables from one server to another in PostgreSQLconnecting Arc 10.3 to a PostGIS database “the coordinate system identifier is invalid”Issues creating ArcSDE sde_logfile for certain users (username begins with a numeral)Importing a CSV with EWKB field into Postgrespostgis raster to postgres databaseCopying tables results in duplication of some tables, feature classes and relationship classes
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to copy the layer_styles table to another database. A quick and painless process is preferred, to make the movement of the layer_styles tables easy to repeat in the future.
I have tried two methods so far:
1. pg_dump and psql
2. Creating a dblink
Neither seem to work. The culprit seems to be the xml type in the layer_styles table.
- I've had success using pg-dump and restore with other tables, however not the layer_styles table. Using pg_restore returns the following error:
ERROR: invalid XML content
DETAIL: line 1: StartTag: invalid element name
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
^
CONTEXT: COPY layer_styles, line 1, column styleqml: "<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis simplifyLocal="1" maxScale="0" minS..."
setval
The end result is an empty layer_styles table in the target database.
- After creating the dblink, I run the following code:
CREATE TABLE layer_styles
AS
SELECT
from dblink('host=localhost
user=postgres
password=postgres
dbname=database3',
'select *
from layer_styles') AS linktable(
a integer,
b varchar,
c varchar,
d varchar,
e text,
f xml,
g xml,
h boolean,
i text,
j varchar,
k xml,
l timestamp);
This returns the following error:
> ERROR: invalid XML content
> DETAIL: line 1: StartTag: invalid element name
> <!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
> ^
I have had previous success with the dblink when using different tables without an XML type.
Does anyone have any advice?
qgis postgresql style table copy
add a comment |
I am trying to copy the layer_styles table to another database. A quick and painless process is preferred, to make the movement of the layer_styles tables easy to repeat in the future.
I have tried two methods so far:
1. pg_dump and psql
2. Creating a dblink
Neither seem to work. The culprit seems to be the xml type in the layer_styles table.
- I've had success using pg-dump and restore with other tables, however not the layer_styles table. Using pg_restore returns the following error:
ERROR: invalid XML content
DETAIL: line 1: StartTag: invalid element name
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
^
CONTEXT: COPY layer_styles, line 1, column styleqml: "<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis simplifyLocal="1" maxScale="0" minS..."
setval
The end result is an empty layer_styles table in the target database.
- After creating the dblink, I run the following code:
CREATE TABLE layer_styles
AS
SELECT
from dblink('host=localhost
user=postgres
password=postgres
dbname=database3',
'select *
from layer_styles') AS linktable(
a integer,
b varchar,
c varchar,
d varchar,
e text,
f xml,
g xml,
h boolean,
i text,
j varchar,
k xml,
l timestamp);
This returns the following error:
> ERROR: invalid XML content
> DETAIL: line 1: StartTag: invalid element name
> <!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
> ^
I have had previous success with the dblink when using different tables without an XML type.
Does anyone have any advice?
qgis postgresql style table copy
add a comment |
I am trying to copy the layer_styles table to another database. A quick and painless process is preferred, to make the movement of the layer_styles tables easy to repeat in the future.
I have tried two methods so far:
1. pg_dump and psql
2. Creating a dblink
Neither seem to work. The culprit seems to be the xml type in the layer_styles table.
- I've had success using pg-dump and restore with other tables, however not the layer_styles table. Using pg_restore returns the following error:
ERROR: invalid XML content
DETAIL: line 1: StartTag: invalid element name
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
^
CONTEXT: COPY layer_styles, line 1, column styleqml: "<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis simplifyLocal="1" maxScale="0" minS..."
setval
The end result is an empty layer_styles table in the target database.
- After creating the dblink, I run the following code:
CREATE TABLE layer_styles
AS
SELECT
from dblink('host=localhost
user=postgres
password=postgres
dbname=database3',
'select *
from layer_styles') AS linktable(
a integer,
b varchar,
c varchar,
d varchar,
e text,
f xml,
g xml,
h boolean,
i text,
j varchar,
k xml,
l timestamp);
This returns the following error:
> ERROR: invalid XML content
> DETAIL: line 1: StartTag: invalid element name
> <!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
> ^
I have had previous success with the dblink when using different tables without an XML type.
Does anyone have any advice?
qgis postgresql style table copy
I am trying to copy the layer_styles table to another database. A quick and painless process is preferred, to make the movement of the layer_styles tables easy to repeat in the future.
I have tried two methods so far:
1. pg_dump and psql
2. Creating a dblink
Neither seem to work. The culprit seems to be the xml type in the layer_styles table.
- I've had success using pg-dump and restore with other tables, however not the layer_styles table. Using pg_restore returns the following error:
ERROR: invalid XML content
DETAIL: line 1: StartTag: invalid element name
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
^
CONTEXT: COPY layer_styles, line 1, column styleqml: "<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis simplifyLocal="1" maxScale="0" minS..."
setval
The end result is an empty layer_styles table in the target database.
- After creating the dblink, I run the following code:
CREATE TABLE layer_styles
AS
SELECT
from dblink('host=localhost
user=postgres
password=postgres
dbname=database3',
'select *
from layer_styles') AS linktable(
a integer,
b varchar,
c varchar,
d varchar,
e text,
f xml,
g xml,
h boolean,
i text,
j varchar,
k xml,
l timestamp);
This returns the following error:
> ERROR: invalid XML content
> DETAIL: line 1: StartTag: invalid element name
> <!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
> ^
I have had previous success with the dblink when using different tables without an XML type.
Does anyone have any advice?
qgis postgresql style table copy
qgis postgresql style table copy
edited Apr 8 at 18:24
underdark♦
69.2k13178348
69.2k13178348
asked Apr 8 at 10:53
DemusDemus
404
404
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Via DB-manager:
- you can load the table into QGIS.
- Then connect to another database
- import the layer_styles-table
Or you can create an empty table in the target_database:
CREATE TABLE public.layer_styles
(
id integer NOT NULL DEFAULT nextval('layer_styles_id_seq'::regclass),
f_table_catalog character varying COLLATE pg_catalog."default",
f_table_schema character varying COLLATE pg_catalog."default",
f_table_name character varying COLLATE pg_catalog."default",
f_geometry_column character varying COLLATE pg_catalog."default",
stylename character varying(30) COLLATE pg_catalog."default",
styleqml xml,
stylesld xml,
useasdefault boolean,
description text COLLATE pg_catalog."default",
owner character varying(30) COLLATE pg_catalog."default",
ui xml,
update_time timestamp without time zone DEFAULT now(),
CONSTRAINT layer_styles_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
Then load the content into it with DB-manager
I am not sure I have done exactly what you've stated. Please instruct if I haven't. In DB Manager, in source database, I exported layer_styles and saved in documents. In DB Manager, in target database, I imported the same file. This returns error message: " Error 6 Feature write errors: Creation error for features from #0 to #0. Provider errors was: PostGIS error while adding features: ERROR: value too long for type character varying(255) Only 0 of 10 features written." Do you know how I should proceed? The resulting layer_styles table in the target database is empty.
– Demus
Apr 8 at 12:59
you should not export the table, just load it in QGIS. Then import it in the target database, using DB-manager. When retrying, be sure to check 'Replace destination table (if exists)'.
– PieterB
Apr 8 at 13:01
I can see it now. I've done as you said and it is working perfectly. For reference for others reading this; ensure you edit the f_table_catalog column to match the name of the new database. Many thanks!
– Demus
Apr 8 at 15:03
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318106%2fcopy-the-layer-styles-table-from-one-database-to-another%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Via DB-manager:
- you can load the table into QGIS.
- Then connect to another database
- import the layer_styles-table
Or you can create an empty table in the target_database:
CREATE TABLE public.layer_styles
(
id integer NOT NULL DEFAULT nextval('layer_styles_id_seq'::regclass),
f_table_catalog character varying COLLATE pg_catalog."default",
f_table_schema character varying COLLATE pg_catalog."default",
f_table_name character varying COLLATE pg_catalog."default",
f_geometry_column character varying COLLATE pg_catalog."default",
stylename character varying(30) COLLATE pg_catalog."default",
styleqml xml,
stylesld xml,
useasdefault boolean,
description text COLLATE pg_catalog."default",
owner character varying(30) COLLATE pg_catalog."default",
ui xml,
update_time timestamp without time zone DEFAULT now(),
CONSTRAINT layer_styles_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
Then load the content into it with DB-manager
I am not sure I have done exactly what you've stated. Please instruct if I haven't. In DB Manager, in source database, I exported layer_styles and saved in documents. In DB Manager, in target database, I imported the same file. This returns error message: " Error 6 Feature write errors: Creation error for features from #0 to #0. Provider errors was: PostGIS error while adding features: ERROR: value too long for type character varying(255) Only 0 of 10 features written." Do you know how I should proceed? The resulting layer_styles table in the target database is empty.
– Demus
Apr 8 at 12:59
you should not export the table, just load it in QGIS. Then import it in the target database, using DB-manager. When retrying, be sure to check 'Replace destination table (if exists)'.
– PieterB
Apr 8 at 13:01
I can see it now. I've done as you said and it is working perfectly. For reference for others reading this; ensure you edit the f_table_catalog column to match the name of the new database. Many thanks!
– Demus
Apr 8 at 15:03
add a comment |
Via DB-manager:
- you can load the table into QGIS.
- Then connect to another database
- import the layer_styles-table
Or you can create an empty table in the target_database:
CREATE TABLE public.layer_styles
(
id integer NOT NULL DEFAULT nextval('layer_styles_id_seq'::regclass),
f_table_catalog character varying COLLATE pg_catalog."default",
f_table_schema character varying COLLATE pg_catalog."default",
f_table_name character varying COLLATE pg_catalog."default",
f_geometry_column character varying COLLATE pg_catalog."default",
stylename character varying(30) COLLATE pg_catalog."default",
styleqml xml,
stylesld xml,
useasdefault boolean,
description text COLLATE pg_catalog."default",
owner character varying(30) COLLATE pg_catalog."default",
ui xml,
update_time timestamp without time zone DEFAULT now(),
CONSTRAINT layer_styles_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
Then load the content into it with DB-manager
I am not sure I have done exactly what you've stated. Please instruct if I haven't. In DB Manager, in source database, I exported layer_styles and saved in documents. In DB Manager, in target database, I imported the same file. This returns error message: " Error 6 Feature write errors: Creation error for features from #0 to #0. Provider errors was: PostGIS error while adding features: ERROR: value too long for type character varying(255) Only 0 of 10 features written." Do you know how I should proceed? The resulting layer_styles table in the target database is empty.
– Demus
Apr 8 at 12:59
you should not export the table, just load it in QGIS. Then import it in the target database, using DB-manager. When retrying, be sure to check 'Replace destination table (if exists)'.
– PieterB
Apr 8 at 13:01
I can see it now. I've done as you said and it is working perfectly. For reference for others reading this; ensure you edit the f_table_catalog column to match the name of the new database. Many thanks!
– Demus
Apr 8 at 15:03
add a comment |
Via DB-manager:
- you can load the table into QGIS.
- Then connect to another database
- import the layer_styles-table
Or you can create an empty table in the target_database:
CREATE TABLE public.layer_styles
(
id integer NOT NULL DEFAULT nextval('layer_styles_id_seq'::regclass),
f_table_catalog character varying COLLATE pg_catalog."default",
f_table_schema character varying COLLATE pg_catalog."default",
f_table_name character varying COLLATE pg_catalog."default",
f_geometry_column character varying COLLATE pg_catalog."default",
stylename character varying(30) COLLATE pg_catalog."default",
styleqml xml,
stylesld xml,
useasdefault boolean,
description text COLLATE pg_catalog."default",
owner character varying(30) COLLATE pg_catalog."default",
ui xml,
update_time timestamp without time zone DEFAULT now(),
CONSTRAINT layer_styles_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
Then load the content into it with DB-manager
Via DB-manager:
- you can load the table into QGIS.
- Then connect to another database
- import the layer_styles-table
Or you can create an empty table in the target_database:
CREATE TABLE public.layer_styles
(
id integer NOT NULL DEFAULT nextval('layer_styles_id_seq'::regclass),
f_table_catalog character varying COLLATE pg_catalog."default",
f_table_schema character varying COLLATE pg_catalog."default",
f_table_name character varying COLLATE pg_catalog."default",
f_geometry_column character varying COLLATE pg_catalog."default",
stylename character varying(30) COLLATE pg_catalog."default",
styleqml xml,
stylesld xml,
useasdefault boolean,
description text COLLATE pg_catalog."default",
owner character varying(30) COLLATE pg_catalog."default",
ui xml,
update_time timestamp without time zone DEFAULT now(),
CONSTRAINT layer_styles_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
Then load the content into it with DB-manager
edited Apr 8 at 13:36
answered Apr 8 at 11:07
PieterBPieterB
3,0101128
3,0101128
I am not sure I have done exactly what you've stated. Please instruct if I haven't. In DB Manager, in source database, I exported layer_styles and saved in documents. In DB Manager, in target database, I imported the same file. This returns error message: " Error 6 Feature write errors: Creation error for features from #0 to #0. Provider errors was: PostGIS error while adding features: ERROR: value too long for type character varying(255) Only 0 of 10 features written." Do you know how I should proceed? The resulting layer_styles table in the target database is empty.
– Demus
Apr 8 at 12:59
you should not export the table, just load it in QGIS. Then import it in the target database, using DB-manager. When retrying, be sure to check 'Replace destination table (if exists)'.
– PieterB
Apr 8 at 13:01
I can see it now. I've done as you said and it is working perfectly. For reference for others reading this; ensure you edit the f_table_catalog column to match the name of the new database. Many thanks!
– Demus
Apr 8 at 15:03
add a comment |
I am not sure I have done exactly what you've stated. Please instruct if I haven't. In DB Manager, in source database, I exported layer_styles and saved in documents. In DB Manager, in target database, I imported the same file. This returns error message: " Error 6 Feature write errors: Creation error for features from #0 to #0. Provider errors was: PostGIS error while adding features: ERROR: value too long for type character varying(255) Only 0 of 10 features written." Do you know how I should proceed? The resulting layer_styles table in the target database is empty.
– Demus
Apr 8 at 12:59
you should not export the table, just load it in QGIS. Then import it in the target database, using DB-manager. When retrying, be sure to check 'Replace destination table (if exists)'.
– PieterB
Apr 8 at 13:01
I can see it now. I've done as you said and it is working perfectly. For reference for others reading this; ensure you edit the f_table_catalog column to match the name of the new database. Many thanks!
– Demus
Apr 8 at 15:03
I am not sure I have done exactly what you've stated. Please instruct if I haven't. In DB Manager, in source database, I exported layer_styles and saved in documents. In DB Manager, in target database, I imported the same file. This returns error message: " Error 6 Feature write errors: Creation error for features from #0 to #0. Provider errors was: PostGIS error while adding features: ERROR: value too long for type character varying(255) Only 0 of 10 features written." Do you know how I should proceed? The resulting layer_styles table in the target database is empty.
– Demus
Apr 8 at 12:59
I am not sure I have done exactly what you've stated. Please instruct if I haven't. In DB Manager, in source database, I exported layer_styles and saved in documents. In DB Manager, in target database, I imported the same file. This returns error message: " Error 6 Feature write errors: Creation error for features from #0 to #0. Provider errors was: PostGIS error while adding features: ERROR: value too long for type character varying(255) Only 0 of 10 features written." Do you know how I should proceed? The resulting layer_styles table in the target database is empty.
– Demus
Apr 8 at 12:59
you should not export the table, just load it in QGIS. Then import it in the target database, using DB-manager. When retrying, be sure to check 'Replace destination table (if exists)'.
– PieterB
Apr 8 at 13:01
you should not export the table, just load it in QGIS. Then import it in the target database, using DB-manager. When retrying, be sure to check 'Replace destination table (if exists)'.
– PieterB
Apr 8 at 13:01
I can see it now. I've done as you said and it is working perfectly. For reference for others reading this; ensure you edit the f_table_catalog column to match the name of the new database. Many thanks!
– Demus
Apr 8 at 15:03
I can see it now. I've done as you said and it is working perfectly. For reference for others reading this; ensure you edit the f_table_catalog column to match the name of the new database. Many thanks!
– Demus
Apr 8 at 15:03
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318106%2fcopy-the-layer-styles-table-from-one-database-to-another%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown