小编muy*_*iwa的帖子

“如何使用 CREATE 方法修复 python IDE 中 sql 中已存在的错误表?”

当我使用时,错误不断弹出Pycharm

Traceback (most recent call last):
  File "C:/Users/aaa/.PyCharmCE2019.2/config/scratches/sql_class.py", line 11, in <module>
    cur.execute(customers_sql)
sqlite3.OperationalError: table customers already exists
Run Code Online (Sandbox Code Playgroud)

我正在使用Pycharm导入 sqlite3

import sqlite3
con = sqlite3.connect('data_info.sqlite3')
# 'connect' is similar to 'open' in a text file
cur = con.cursor()
# instantiate a cursor obj
customers_sql = """
      CREATE TABLE customers (
      id integer PRIMARY KEY,
      first_name text NOT NULL,
      last_name text NOT NULL)"""
cur.execute(customers_sql)


products_sql = """
      CREATE TABLE products (
      id integer PRIMARY KEY,
      name text …
Run Code Online (Sandbox Code Playgroud)

python sql python-3.x

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×1

python-3.x ×1

sql ×1