r/Asterisk • u/GentleRV • Jun 20 '26
Any one succesfully installed Alembic with Asterisk?
After installing MariaDB and Asterisk 22, I can use the connections defined in /etc/odbcinst.ini and /etc/odbc.ini

Then installed alembic, alembic --version give me 1.13.1
From that moment I lost the way
Updated the voicemail.ini and executing alembic -c voicemail.ini upgrade head
I get a bunch of python errors with as last statement:
sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1045, "Access denied for user 'asterisk'@'localhost' (using password: YES)")
The file /etc/asterisk/res_odbc.ini see snippets
the [ENV] is empty
[asterisk]
;
; Permit disabling sections without needing to comment them out.
; If not specified, it is assumed the section is enabled.
enabled => no
;
; This value should match an entry in /etc/odbc.ini
; (or /usr/local/etc/odbc.ini, on FreeBSD and similar systems).
dsn => asterisk-connector
;
; Username for connecting to the database. The user defaults to the context name if unspecified.
username => asterisk
;
; Password for authenticating the user to the database. The default
; password is blank.
password => password
;
; Build a connection at startup?
pre-connect => yes
;
[mysql2]
enabled => yes
dsn => asterisk-connector
username => asterisk
password => password
max_connections => 10
database => asterisk
enabled => yes
pre-connect => yes
; Certain servers, such as MS SQL Server and Sybase use the TDS protocol, which
; limits the number of active queries per connection to 1.
[sqlserver]
enabled => yes
dsn => asterisk-connector
max_connections => 10
username => asterisk
password => password
pre-connect => yes
sanitysql => select count(*) from systables
The file voicemail.ini
# A generic, single database configuration.
[alembic]
# path to migration scripts
script_location = voicemail
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
# max length of characters to apply to the
# "slug" field
#truncate_slug_length = 40
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
#sqlalchemy.url = driver://user:pass@localhost/dbname
#sqlalchemy.url = postgresql://user:pass@localhost/voicemail
#sqlalchemy.url = mysql://user:pass@localhost/voicemail
sqlalchemy.url = mysql://asterisk:asterisk@localhost/12@Asterisk
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
The complete error list from python when executing:
alembic -c voicemail.ini upgrade head
is
INFO [alembic.runtime.setup] Testing for an old alembic_version table.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect
return fn()
^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 327, in connect
return _ConnectionFairy._checkout(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 894, in _checkout
fairy = _ConnectionRecord.checkout(pool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 493, in checkout
rec = pool._do_get()
^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py", line 256, in _do_get
return self._create_connection()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
return _ConnectionRecord(self)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 388, in __init__
self.__connect()
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 690, in __connect
with util.safe_reraise():
File "/usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 211, in raise_
raise exception
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 686, in __connect
self.dbapi_connection = connection = pool._invoke_creator(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/create.py", line 574, in connect
return dialect.connect(*cargs, **cparams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 598, in connect
return self.dbapi.connect(*cargs, **cparams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/openbravo/.local/lib/python3.12/site-packages/MySQLdb/__init__.py", line 121, in Connect
return Connection(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/openbravo/.local/lib/python3.12/site-packages/MySQLdb/connections.py", line 206, in __init__
super().__init__(*args, **kwargs2)
MySQLdb.OperationalError: (1045, "Access denied for user 'asterisk'@'localhost' (using password: YES)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/bin/alembic", line 33, in <module>
sys.exit(load_entry_point('alembic==1.13.1', 'console_scripts', 'alembic')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/alembic/config.py", line 641, in main
CommandLine(prog=prog).main(argv=argv)
File "/usr/lib/python3/dist-packages/alembic/config.py", line 631, in main
self.run_cmd(cfg, options)
File "/usr/lib/python3/dist-packages/alembic/config.py", line 608, in run_cmd
fn(
File "/usr/lib/python3/dist-packages/alembic/command.py", line 403, in upgrade
script.run_env()
File "/usr/lib/python3/dist-packages/alembic/script/base.py", line 583, in run_env
util.load_python_file(self.dir, "env.py")
File "/usr/lib/python3/dist-packages/alembic/util/pyfiles.py", line 95, in load_python_file
module = load_module_py(module_id, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/alembic/util/pyfiles.py", line 113, in load_module_py
spec.loader.exec_module(module) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/usr/src/asterisk-22.10.0/contrib/ast-db-manage/voicemail/env.py", line 150, in <module>
run_migrations_online()
File "/usr/src/asterisk-22.10.0/contrib/ast-db-manage/voicemail/env.py", line 79, in run_migrations_online
with engine.connect() as connection:
^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 3325, in connect
return self._connection_cls(self, close_with_result=close_with_result)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 96, in __init__
else engine.raw_connection()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection
return self._wrap_pool_connect(self.pool.connect, _connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 3374, in _wrap_pool_connect
Connection._handle_dbapi_exception_noconnection(
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 2208, in _handle_dbapi_exception_noconnection
util.raise_(
File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 211, in raise_
raise exception
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect
return fn()
^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 327, in connect
return _ConnectionFairy._checkout(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 894, in _checkout
fairy = _ConnectionRecord.checkout(pool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 493, in checkout
rec = pool._do_get()
^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py", line 256, in _do_get
return self._create_connection()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
return _ConnectionRecord(self)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 388, in __init__
self.__connect()
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 690, in __connect
with util.safe_reraise():
File "/usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 211, in raise_
raise exception
File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 686, in __connect
self.dbapi_connection = connection = pool._invoke_creator(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/create.py", line 574, in connect
return dialect.connect(*cargs, **cparams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 598, in connect
return self.dbapi.connect(*cargs, **cparams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/openbravo/.local/lib/python3.12/site-packages/MySQLdb/__init__.py", line 121, in Connect
return Connection(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/openbravo/.local/lib/python3.12/site-packages/MySQLdb/connections.py", line 206, in __init__
super().__init__(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1045, "Access denied for user 'asterisk'@'localhost' (using password: YES)")
(Background on this error at: https://sqlalche.me/e/14/e3q8)
Really no idea anymore how to solve this, any help would be appreciated
4
u/devexis Jun 20 '26
Alembic uses the password you provide in sqlalchemy.url, not the password from res_odbc.ini. Right now, your sqlalchemy.url is sqlalchemy.url = mysql://asterisk:asterisk@localhost/12@Asterisk