Search code examples
mysqlballerina

Undefined Module Mysl - Ballerina


I'm following the course on Integration with Ballerina. I'm trying to create a mysql connection on a bal file, but I get an "undefined module" error. Mysql is not being suggested as shown in the screenshot. Have I missed to add something? Do I need to add an entry for MYSQL into the toml file?

enter image description here

I tried to add - import ballerinax/mysql; - it gives an error saying cannot resolve module 'ballerinax/mysql'


Solution

  • Only the packages in the local central repository are shown as a suggestion in the VS code. Since you did not pulled this package yet, you are not getting the suggestions. You could try the following approaches:

    1. Manually pull the package using the following command and restart the VSCode
    bal pull ballerinax/mysql
    
    1. Simply add the import statement. This will show an unresolved module error if the package is not pulled before. You can click on the Quick Fix in the VSCode to pull the package
    import ballerinax/mysql;