Answer the question
In order to leave comments, you need to log in
How to pass the result of a sql query to a variable in python?
Good afternoon, I can not understand what is the reason, I am trying to get the location of the directory of all databases from sql and put this case into a variable.
db = MySQLdb.connect(hostaddress,user,password,db_name)
cursor = db.cursor()
cursor.execute("SELECT @@datadir")
getsql = cursor.fetchall
os.rename(getsql + database, '/tmp/backup/DATABASES/' + database)
db.close()
except Exception as err:
logging.error(str(err))
ERROR:mysql:can only concatenate tuple (not "str") to tuple
SELECT @@datadir
Answer the question
In order to leave comments, you need to log in
Look at what data types "getsql" and "database" store, you will immediately understand what the error is.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question