From b061d3e9508435b4c9c687743a2c95e385815637 Mon Sep 17 00:00:00 2001 From: schlatterbeck Date: Wed, 16 Mar 2011 11:26:50 +0000 Subject: [PATCH] Configuration issue: On some postgresql 8.4 installations (notably on debian squeeze) the default template database used for database creation doesn't match the needed character encoding UTF8 -- a new config option 'template' in the rdbms section now allows specification of the template. You know you need this option if you get the error message: psycopg2.DataError: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) HINT: Use the same encoding as in the template database, or use template0 as template. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4580 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 11 +++++++++++ roundup/backends/back_postgresql.py | 2 ++ roundup/configuration.py | 12 ++++++++++++ 3 files changed, 25 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 67b6702..6f33989 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -42,6 +42,17 @@ Fixed: (Ralf Schlatterbeck) - Fix incorrect setting of template in customizing.txt example action, patch via issue2550682 (thanks John Kristensen) +- Configuration issue: On some postgresql 8.4 installations (notably on + debian squeeze) the default template database used for database + creation doesn't match the needed character encoding UTF8 -- a new + config option 'template' in the rdbms section now allows specification + of the template. You know you need this option if you get the error + message: + psycopg2.DataError: new encoding (UTF8) is incompatible with the + encoding of the template database (SQL_ASCII) + HINT: Use the same encoding as in the template database, or use + template0 as template. + (Ralf Schlatterbeck) 2010-10-08 1.4.16 (r4541) diff --git a/roundup/backends/back_postgresql.py b/roundup/backends/back_postgresql.py index d43659e..0981262 100644 --- a/roundup/backends/back_postgresql.py +++ b/roundup/backends/back_postgresql.py @@ -36,6 +36,8 @@ def connection_dict(config, dbnamestr=None): def db_create(config): """Clear all database contents and drop database itself""" command = "CREATE DATABASE %s WITH ENCODING='UNICODE'"%config.RDBMS_NAME + if config.RDBMS_TEMPLATE : + command = command + " TEMPLATE=%s" % config.RDBMS_TEMPLATE logging.getLogger('roundup.hyperdb').info(command) db_command(config, command) diff --git a/roundup/configuration.py b/roundup/configuration.py index 8e42cef..b145e96 100644 --- a/roundup/configuration.py +++ b/roundup/configuration.py @@ -610,6 +610,18 @@ SETTINGS = ( "Only used in SQLite connections."), (IntegerNumberOption, 'cache_size', '100', "Size of the node cache (in elements)"), + (NullableOption, 'template', '', + "Name of the PostgreSQL template for database creation.\n" + "For database creation the template used has to match\n" + "the character encoding used (UTF8), there are different\n" + "PostgreSQL installations using different templates with\n" + "different encodings. If you get an error:\n" + " new encoding (UTF8) is incompatible with the encoding of\n" + " the template database (SQL_ASCII)\n" + " HINT: Use the same encoding as in the template database,\n" + " or use template0 as template.\n" + "then set this option to the template name given in the\n" + "error message."), ), "Settings in this section are used" " by RDBMS backends only" ), -- 2.30.2