0

I am building a webtool using flask and now working on the database migration. the database I am using is MariaDB. I managed to install the database correctly and completely and managed to start is using :

mysql.server start

also I managed to enter the DB environment and create a database. from my flask application I am using sqlalchemy to connect the application and database. also I am developing the application on my mac machine. if I do:

flask run

the application works without error but if I run this command:

flask db migrate

I will get the following error. do you know how I can fix it? :

Traceback (most recent call last):
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/pymysql/connections.py", line 613, in connect
    sock = socket.create_connection(
  File "/Users/miniconda3/lib/python3.9/socket.py", line 822, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/Users/miniconda3/lib/python3.9/socket.py", line 953, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3280, in _wrap_pool_connect
    return fn()
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 310, in connect
    return _ConnectionFairy._checkout(self)
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 868, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 476, in checkout
    rec = pool._do_get()
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 146, in _do_get
    self._dec_overflow()
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
    raise exception
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 256, in _create_connection
    return _ConnectionRecord(self)
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 371, in __init__
    self.__connect()
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 666, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
    raise exception
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 661, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 590, in connect
    return dialect.connect(*cargs, **cparams)
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 597, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/pymysql/connections.py", line 353, in __init__
    self.connect()
  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/pymysql/connections.py", line 664, in connect
    raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '123456@localhost' ([Errno 8] nodename nor servname provided, or not known)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/Desktop/blog_example/blog/bin/flask", line 8, in <module>
    sys.exit(main())

  File "/Users/Desktop/blog_example/blog/lib/python3.9/site-packages/pymysql/connections.py", line 664, in connect
    raise exc
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '123456@localhost' ([Errno 8] nodename nor servname provided, or not known)")
(Background on this error at: https://sqlalche.me/e/14/e3q8)
bioinfo
  • 7
  • 1

0 Answers0