1
resposta

Erro ao rodar o Script twitter_hook

fiz o codigo iqual ao que passoi no aula porem esta apresentando na def run quando cria a sesseion = self.get_conn()

segue erro

Traceback (most recent call last):
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context
    self.dialect.do_execute(
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: connection

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

Traceback (most recent call last):
  File "twitter_hook.py", line 58, in <module>
    for pg in TwitterHook("AluraOnline").run():
  File "twitter_hook.py", line 51, in run
    session = self.get_conn()
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/airflow/hooks/http_hook.py", line 62, in get_conn
    conn = self.get_connection(self.http_conn_id)
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/airflow/hooks/base_hook.py", line 87, in get_connection
    conn = random.choice(list(cls.get_connections(conn_id)))
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/airflow/hooks/base_hook.py", line 83, in get_connections
    return secrets.get_connections(conn_id)
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/airflow/secrets/__init__.py", line 55, in get_connections
    conn_list = secrets_backend.get_connections(conn_id=conn_id)
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/airflow/utils/db.py", line 74, in wrapper
    return func(*args, **kwargs)
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/airflow/secrets/metastore.py", line 35, in get_connections
    conn_list = session.query(Connection).filter(Connection.conn_id == conn_id).all()
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3373, in all
    return list(self)
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
    return self._execute_and_instances(context)
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
    return meth(self, multiparams, params)
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1124, in _execute_clauseelement
    ret = self._execute_context(
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1316, in _execute_context
    self._handle_dbapi_exception(
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1510, in _handle_dbapi_exception
    util.raise_(
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context
    self.dialect.do_execute(
  File "/home/andre/Documents/datapipeline/.env/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: connection
[SQL: SELECT connection.password AS connection_password, connection.extra AS connection_extra, connection.id AS connection_id, connection.conn_id AS connection_conn_id, connection.conn_type AS connection_conn_type, connection.host AS connection_host, connection.schema AS connection_schema, connection.login AS connection_login, connection.port AS connection_port, connection.is_encrypted AS connection_is_encrypted, connection.is_extra_encrypted AS connection_is_extra_encrypted
FROM connection
WHERE connection.conn_id = ?]
[parameters: ('twitter_default',)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
1 resposta

A tabela onde fica o conector não esta sendo encontrado de acordo com o erro. voce poderia tentar:

  • Apagar o arquivo sqlite chamado airflow.db;
  • rodar o comando airflow initdb;
  • Criar dinovo o connector no webserver; Tenta esses passos e informa se deu certo