[OpenSIPS-Users] Cannot create opensips database for postgresql using opensips-cli

Tekin, Arda arda.tekin at afiniti.com
Thu Feb 13 05:28:45 EST 2020


Hi Ryan

I have recently created the postgres tables by opensips-cli tool.
Copy the default.cfg under your home directory. (while I am root)
cp /root/src/opensips-cli/etc/default.cfg /root/opensips-cli.cfg

add postgres section in opensips-cli.cfg.

The postgres password should be previously set by psql command.

My file looks like this

[default]
log_level: WARNING
prompt_name: opensips-cli
prompt_intro: Welcome to OpenSIPS Command Line Interface!
prompt_emptyline_repeat_cmd: False
history_file: ~/.opensips-cli.history
history_file_size: 1000
output_type: pretty-print
communication_type: fifo
fifo_file: /tmp/opensips_fifo

# optional DB override instance, invoked using `opensips-cli -i postgres ...`
[postgres]
database_path: /usr/local/share/opensips/postgres
database_url: postgres://opensips:<postgres-password>@<db-ip>:5432
template_url: postgres://postgres:<postgres-password>@<db-ip>:5432
database_name: opensips


Then run the following command to create all tables of opensips

opensips-cli -f /root/opensips-cli.cfg -i postgres -x database create


opensips-cli uses the sql files in /usr/local/share/opensips/postgres path when creating tables.


Arda

From: Users <users-bounces at lists.opensips.org> On Behalf Of Ryan embgrets
Sent: Monday, February 10, 2020 12:22 AM
To: users at lists.opensips.org
Subject: [OpenSIPS-Users] Cannot create opensips database for postgresql using opensips-cli


Attention: This email was sent from someone outside of Afiniti. Always use caution when opening attachments, clicking links from unknown senders or when receiving unexpected emails.


Greetings,

I am trying to create opensips database using opensips-cli module but each time it is failing.
I am getting below error during the process.

(opensips-cli): database create
Please provide the URL of the SQL database: postgres://opensips:opensipsrw@127.0.0.1<mailto:opensips%3Aopensipsrw@127.0.0.1>
ERROR: cannot connect to DB server: (psycopg2.OperationalError) FATAL:  database "opensips" does not exist
!
Traceback (most recent call last):
  File "/usr/lib/python3.5/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/lib/python3/dist-packages/sqlalchemy/pool.py", line 1044, in _do_get
    return self._pool.get(wait, self._timeout)
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/queue.py", line 145, in get
    raise Empty
sqlalchemy.util.queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 2074, in _wrap_pool_connect
    return fn()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 318, in unique_connection
    return _ConnectionFairy._checkout(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 713, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 480, in checkout
    rec = pool._do_get()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 1060, in _do_get
    self._dec_overflow()
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 1057, in _do_get
    return self._create_connection()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 323, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 449, in __init__
    self.connection = self.__connect()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool.py", line 607, in __connect
    connection = self.__pool._invoke_creator(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/strategies.py", line 97, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 385, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL:  database "opensips" does not exist

Any help here is much appreciated.

Ryan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20200213/a803d336/attachment-0001.html>


More information about the Users mailing list