0

I set up a project following this tutorial in YouTube: https://www.youtube.com/watch?v=nynySD0WoYQ

In this tutorial, GraphQL is used with FastAPI and the strawberry library. Furthermore, docker is used in order to create and connect with MySQL database. Everything works fine but I wanted to connect a second table to my database and this is not working. In the tutorial one database table called users is connected and I tried to connect a second one called computers.

I have the following folder structure in my project:

folder strcuture

Content of docker-compose.yml is this:

version: '3.8'
services:
  db:
    image: mysql
    volumes:
      - ./data/mysql:/var/lib/mysql
    ports:
      - '3306:3306'
    environment:
      MYSQL_ROOT_PASSWORD: 'root'
      MYSQL_DATABASE: 'test'

Content of controllers/index.py is:

from controllers.user import user
from controllers.computer import computer

And there I get the message that the second import from controllers.computer import computer is unused.

main.py looks like this:

from fastapi import FastAPI
from controllers.index import user, computer

app = FastAPI()
app.include_router(user)
app.include_router(computer)

Which other information is necessary to solve this problem? I can just state that I changed the code for the computer.py files accordingly to that what I had for the user.py files and imported correctly in my opinion in all files.

Tobitor
  • 1,388
  • 1
  • 23
  • 58

0 Answers0