Problem with deploy database to PostgreSQL from Ubuntu
Shkiperon opened this issue · 1 comments
Shkiperon commented
I have the crash when try to create database for Opensips 3.1
My cfg file for cli:
[default]
prompt_name: proxy
fifo_file: /tmp/opensips_fifo
database_schema_path: /usr/src/opensips-31/scripts
database_admin_url: postgres://postgres:Megapassword@192.168.0.10:5432
database_url: postgres://opensipsuser:OpensipsPassword@192.168.0.10:5432
database_name: opensips_test
database_modules: ALL
Part of traceback:
INFO: role 'opensipsuser' with options 'NOCREATEDB NOCREATEROLE LOGIN' created
INFO: GRANT ALL PRIVILEGES ON DATABASE opensips_test TO opensipsuser
Traceback (most recent call last):
File "/usr/lib/python3.8/cmd.py", line 214, in onecmd
func = getattr(self, 'do_' + cmd)
AttributeError: 'OpenSIPSCLIShell' object has no attribute 'do_database'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 363, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 760, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 492, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 139, in _do_get
self._dec_overflow()
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", line 68, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/util/compat.py", line 129, in reraise
raise value
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 136, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 308, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 437, in __init__
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 639, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/engine/default.py", line 453, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.8/dist-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: database "opensipsuser" does not exist
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/opensips-cli", line 4, in <module>
__import__('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli')
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 667, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1463, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.8/dist-packages/opensipscli-0.1.0-py3.8.egg/EGG-INFO/scripts/opensips-cli", line 9, in <module>
run_console()
File "/usr/local/lib/python3.8/dist-packages/opensipscli-0.1.0-py3.8.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
main.main()
File "/usr/local/lib/python3.8/dist-packages/opensipscli-0.1.0-py3.8.egg/opensipscli/main.py", line 78, in main
sys.exit(shell.cmdloop())
File "/usr/local/lib/python3.8/dist-packages/opensipscli-0.1.0-py3.8.egg/opensipscli/cli.py", line 253, in cmdloop
super(OpenSIPSCLIShell, self).cmdloop(intro='')
File "/usr/lib/python3.8/cmd.py", line 138, in cmdloop
stop = self.onecmd(line)
File "/usr/lib/python3.8/cmd.py", line 216, in onecmd
return self.default(line)
File "/usr/local/lib/python3.8/dist-packages/opensipscli-0.1.0-py3.8.egg/opensipscli/cli.py", line 374, in default
self.run_command(module, cmd, params)
File "/usr/local/lib/python3.8/dist-packages/opensipscli-0.1.0-py3.8.egg/opensipscli/cli.py", line 357, in run_command
return mod[0].__invoke__(cmd, params)
File "/usr/local/lib/python3.8/dist-packages/opensipscli-0.1.0-py3.8.egg/opensipscli/module.py", line 36, in __invoke__
return f(params)
File "/usr/local/lib/python3.8/dist-packages/opensipscli-0.1.0-py3.8.egg/opensipscli/modules/database.py", line 385, in do_create
if self.create_tables(db_name, db_url, admin_db) < 0:
File "/usr/local/lib/python3.8/dist-packages/opensipscli-0.1.0-py3.8.egg/opensipscli/modules/database.py", line 428, in create_tables
if not db.exists():
File "/usr/local/lib/python3.8/dist-packages/opensipscli-0.1.0-py3.8.egg/opensipscli/db.py", line 526, in exists
if sqlalchemy_utils.database_exists(database_url):
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy_utils/functions/database.py", line 466, in database_exists
return bool(get_scalar_result(engine, text))
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy_utils/functions/database.py", line 445, in get_scalar_result
result_proxy = engine.execute(sql)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2165, in execute
connection = self._contextual_connect(close_with_result=True)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2226, in _contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2265, in _wrap_pool_connect
Connection._handle_dbapi_exception_noconnection(
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1536, in _handle_dbapi_exception_noconnection
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 363, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 760, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 492, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 139, in _do_get
self._dec_overflow()
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", line 68, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/util/compat.py", line 129, in reraise
raise value
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/impl.py", line 136, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 308, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 437, in __init__
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/pool/base.py", line 639, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.8/dist-packages/SQLAlchemy-1.3.3-py3.8-linux-x86_64.egg/sqlalchemy/engine/default.py", line 453, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.8/dist-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL: database "opensipsuser" does not exist
(Background on this error at: http://sqlalche.me/e/e3q8)
Looks like some problems with variables in script, but I don't understand where.
Shkiperon commented
If database name and user name is the same - works fine.