You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting an error when trying to use opensips-cli to create the database tables on a postgres database. When I use the mysql config, it connects and creates the database and adds the tables with no problems. But, when I try with postgres, I get the error below.
root@006fddf43be7:/# opensips-cli -x database create
Traceback (most recent call last):
File "/usr/bin/opensips-cli", line 9, in <module>
run_console()
File "/usr/bin/opensips-cli", line 6, in run_console
main.main()
File "/usr/lib/python3/dist-packages/opensipscli/main.py", line 77, in main
shell = cli.OpenSIPSCLI(args)
File "/usr/lib/python3/dist-packages/opensipscli/cli.py", line 90, in __init__
self.update_instance(cfg.current_instance)
File "/usr/lib/python3/dist-packages/opensipscli/cli.py", line 166, in update_instance
excl_mod = mod.__exclude__(mod)
File "/usr/lib/python3/dist-packages/opensipscli/modules/database.py", line 469, in __exclude__
return (not osdb.has_dialect(osdb.get_dialect(db_url)), None)
File "/usr/lib/python3/dist-packages/opensipscli/db.py", line 767, in has_dialect
sqlalchemy.create_engine('{}://'.format(dialect))
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/__init__.py", line 520, in create_engine
return strategy.create(*args, **kwargs)
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/strategies.py", line 87, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/usr/lib/python3/dist-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 778, in dbapi
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
I have confirmed that connecting with postgres via psql works just fine. I'm not super familiar with the opensips-cli python code to know where to go next.
Here is a way to recreate the issue exactly like I am if that helps:
docker compose.yml:
version: "3.9"networks:
net:
driver: bridgeipam:
config:
- subnet: 172.20.0.0/16services:
postgres:
image: postgres:16.4ports:
- 5432:5432volumes:
- ./docker/docker-postgres:/var/lib/postgresql/dataenvironment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
- DB_ANON_ROLE=${DB_ANON_ROLE}
- DB_SCHEMA=${DB_SCHEMA}restart: alwaysnetworks:
net:
ipv4_address: 172.20.0.10mysql:
image:
mysql:8.0# NOTE: use of "mysql_native_password" is not recommended: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password# (this is just an example, not intended to be a production configuration)command: --default-authentication-plugin mysql_native_passwordvolumes:
- ./docker/docker-mysql/.db_data:/var/lib/mysql
- ./docker/docker-mysql/initdb/:/docker-entrypoint-initdb.d/restart: alwaysstdin_open: truetty: trueports:
- "3306:3306"environment:
MYSQL_ROOT_PASSWORD: passwordMYSQL_DATABASE: opensipsMYSQL_USER: opensipsMYSQL_PASSWORD: opensipsrwhealthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]timeout: 20sretries: 10networks:
net:
ipv4_address: 172.20.0.13
POSTGRES_USER=postgres POSTGRES_DB=postgres DB_ANON_ROLE=web_anon DB_SCHEMA=postgres POSTGRES_PASSWORD=postgres docker compose up
I am getting an error when trying to use opensips-cli to create the database tables on a postgres database. When I use the mysql config, it connects and creates the database and adds the tables with no problems. But, when I try with postgres, I get the error below.
Here is my opensips-cli.cfg with both options.
I have confirmed that connecting with postgres via psql works just fine. I'm not super familiar with the opensips-cli python code to know where to go next.
Here is a way to recreate the issue exactly like I am if that helps:
docker compose.yml:
Run opensips:
docker run -it \ --network test_net \ --ip 172.20.0.11 \ -v ${PWD}/opensips/:/etc/opensips \ --entrypoint /bin/bash \ opensips/opensips:latest
(DOCKERSHELL)# opensips-cli -x database create
I am using postgres 16, so maybe something changed. I can try tomorrow on an older version of postgres, and see if that makes a difference.
The text was updated successfully, but these errors were encountered: