Промяна на PostgreSQL default template0 на UTF8 encoding
При инсталация на PostgreSQL (за управение на бaзата данни на OpenERP) енкодинgа по подразбиране не е UTF8, с какъвто работи OpenERP 7.0. При опит за създаване на база данни се получава следното съобщение за грешка:
Client Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/http.py", line 195, in dispatch response["result"] = method(self, **self.params) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 718, in create params['create_admin_pwd']) File "/opt/openerp/server/openerp/addons/web/session.py", line 31, in proxy_method result = self.session.send(self.service_name, method, *args) File "/opt/openerp/server/openerp/addons/web/session.py", line 104, in send raise xmlrpclib.Fault(openerp.tools.exception_to_unicode(e), formatted_info) Server Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/session.py", line 90, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/opt/openerp/server/openerp/netsvc.py", line 289, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/server/openerp/service/web_services.py", line 122, in dispatch return fn(*params) File "/opt/openerp/server/openerp/service/web_services.py", line 167, in exp_create_database self._create_empty_database(db_name) File "/opt/openerp/server/openerp/service/web_services.py", line 136, in _create_empty_database cr.execute("""CREATE DATABASE "%s" ENCODING 'unicode' TEMPLATE "%s" """ % (name, chosen_template)) File "/opt/openerp/server/openerp/sql_db.py", line 162, in wrapper return f(self, *args, **kwargs) File "/opt/openerp/server/openerp/sql_db.py", line 227, in execute res = self._obj.execute(query, params) 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.
Този проблем се решава лесно, като се смени енкодинга по подразбиране на PostgreSQL на UTF8 по следния начин:
root@server:~# su postgres
Ctrl+Z
postgres@server:~ $ psql -U postgres
psql (9.0.3)
Type "help" for help.
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0';
UPDATE 1
postgres=# \c template0
You are now connected to database "template0".
template0=# update pg_database set datistemplate = FALSE where datname = 'template1';
UPDATE 1
template0=# drop database template1;
DROP DATABASE
template0=# create database template1 with template = template0 encoding = 'UTF8';
CREATE DATABASE
template0=# update pg_database set datistemplate = TRUE where datname = 'template1';
UPDATE 1
template0=# \c template1
You are now connected to database "template1".
template1=# update pg_database set datallowconn = FALSE where datname = 'template0';
UPDATE 1
template1=#
postgres@server:~ $ exit
root@server:~#
Сега вече можете да създадете първата си база данни.