0

我创建了一个 SQLite 数据库。它在没有虚拟表的情况下运行良好,但是当我在代码中添加虚拟表时,它会发送以下错误。

我创建了一个数据库:

sqls = ["CREATE INDEX companyIdIdx ON one(companyId)",
        "CREATE INDEX companyIdIdxIndTree ON two(companyId)",
        "CREATE INDEX companyIdBusinessDesc ON three(companyId)",
        "CREATE VIRTUAL TABLE DescTbl USING FTS5(companyId,businessDescription)",
        "INSERT INTO DescTbl SELECT companyId,businessDescription FROM ciqBusinessDescription"]

for sql in sqls :
    try :
        basecon.execute(sql)
    except Exception as e :
        print(e.args)
        pass
    
basecon.commit()

然后我运行代码:

pd.read_sql("SELECT * FROM sqlite_master",con)

这给出了错误:

--------------------------------------------------------------------------
DatabaseError                             Traceback (most recent call last)
/usr/local/lib64/python3.6/site-packages/pandas/io/sql.py in execute(self, *args, **kwargs)
   1680         try:
-> 1681             cur.execute(*args, **kwargs)
   1682             return cur

DatabaseError: malformed database schema (DescTbl_config) - near "WITHOUT": syntax error

The above exception was the direct cause of the following exception:

DatabaseError                             Traceback (most recent call last)
<ipython-input-7-230e094dfbb2> in <module>
----> 1 pd.read_sql("SELECT * FROM sqlite_master",con)

/usr/local/lib64/python3.6/site-packages/pandas/io/sql.py in read_sql(sql, con, index_col, coerce_float, params, parse_dates, columns, chunksize)
    487             coerce_float=coerce_float,
    488             parse_dates=parse_dates,
--> 489             chunksize=chunksize,
    490         )
    491 

/usr/local/lib64/python3.6/site-packages/pandas/io/sql.py in read_query(self, sql, index_col, coerce_float, params, parse_dates, chunksize)
   1725 
   1726         args = _convert_params(sql, params)
-> 1727         cursor = self.execute(*args)
   1728         columns = [col_desc[0] for col_desc in cursor.description]
   1729 

/usr/local/lib64/python3.6/site-packages/pandas/io/sql.py in execute(self, *args, **kwargs)
   1691 
   1692             ex = DatabaseError(f"Execution failed on sql '{args[0]}': {exc}")
-> 1693             raise ex from exc
   1694 
   1695     @staticmethod

DatabaseError: Execution failed on sql 'SELECT * FROM sqlite_master': malformed database schema (DescTbl_config) - near "WITHOUT": syntax erro

r

4

0 回答 0