-1

I am trying to use Flask on my pc but I keep getting an error whenever I import from the sql module. The error states:

ImportError: cannot import name 'create_connection' from 'sql' (C:<Directory to sql.py>)

# Imports
import flask
from flask import jsonify
from flask import request
import mysql.connector
from mysql.connector import Error
from sql import create_connection
from sql import execute_read_query

What can I do to fix this?

  • Please [edit] the question to include the _complete_ error traceback. The code in sql.py may also be needed if it is code that you wrote. If it's from a third-party package please provide a link to its project homepage. – snakecharmerb Mar 04 '23 at 12:09

1 Answers1

0

I think it's the file path problem or package install issue. If you confirm your project path don't have the same file named "sql.py", you can try to below command:

pip uninstall python-sql

then

pip install python-sql
Ryan Lin
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Blue Robin Mar 09 '23 at 04:26