首页 > 解决方案 > execute 是 mysql.connector 的一个属性,但是当我使用它时显示无效

问题描述

import mysql.connector as  sql   
conn=sql.connect(host='localhost',user='root',password='09062003',database='grocery_shop',charset='utf8')
c=conn.cursor
c.execute('create table if not exists product_details(product_name varchar(25),product_cost float(10))')
print('Product Table Created')

它返回以下错误::

文件“G:\DANGER\InformaticsPractices\IP Project\Grocery Store Management\Grocery Store Management System.py”,第 36 行,在 CreateCust c.execute('create table if not exists customer_details(phone_no int(13),cust_name varchar( 25),cost float(10))') AttributeError: 'function' object has no attribute 'execute'

据我所知,execute 是 mysql.connector 的一个属性

标签: mysql

解决方案


推荐阅读