0

I am using the mysql.connect library. I'd like to have a function that returns a connection and a cursor, but trying to annotate it always leads to errors like 'MySQLConnection is not defined'.

  cnx: MySQLConnection = mysql.connector.connect(user='root', password='toor', host='127.0.0.1')
  # "MySQLConnection" is not defined

How am I supposed to annotate this ?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
muchos
  • 41
  • 5
  • How can I mark this as answered ? – muchos Mar 22 '23 at 09:29
  • 1
    You need to write an answer yourself and mark it as accepted. – elburro1887 Mar 22 '23 at 09:31
  • Fill in the "Your Answer" textarea below and then click "Post Your Answer" button. Note that `from some_module import *` [is not considered to be good style](https://stackoverflow.com/q/2386714/5320906). `from some_module import SomeSpecificName` would be better. – snakecharmerb Mar 22 '23 at 09:34

1 Answers1

-1
import mysql.connector
from mysql.connector.cursor import CursorBase
from mysql.connector.connection import MySQLConnection
muchos
  • 41
  • 5
  • 1
    Please don't post only code as answer, but also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes. – Mark Rotteveel Mar 23 '23 at 09:25