I have a DB and when I query a table I get 67 results. The SQL is: I try to connect to the DB, and I get no connection errors. It prints out -1 for rowcount. The connection to the DB appears to be working, the SQL is a simple query… Answer Try adding cursor.fetchall() before the print(cursor.rowcount)
Tag: mysql-connector
Retrive data of last month using Python with source as MYSQL
I am getting an error while retrieving data of the last month using python. What is the best approach for the given piece of code? I am not able to get solution, What changes can I do. I am using MYSQL as my source database and Python 3.7.4 as my programming language. Since error is big, posting it in two
How to add placeholder in python for creating table name in mysql database?
here i want to name the table name according to user desire but i can’t please help ** I HAVE INCLUDED THIS CODES FOR CONNECTING PYTHON TO DATABASE ** Answer The syntax for creating a table in mySql looks like this: This will create the table named “my_table_name” with one column named “my_first_column” of type integer. To implement this in
How to get column names from a SQL query?
I need to put data from the SQL query into a Pandas dataframe. Please tell me is it possible to get column names the query results? I found that there is a keys() function in sqlalchemy for that but it does not work for me: AttributeError: ‘CMySQLCursor’ object has no attribute ‘keys’ Answer I think that it your are searching