提问人:MrMonster1 提问时间:11/15/2023 最后编辑:XedniMrMonster1 更新时间:11/15/2023 访问量:30
当数据库链接到 SharePoint 列表时,如何将数据从 Python 发送到 Access?
How to send data from Python to Access when the database is linked to a SharePoint list?
问:
每个人 都!
我的代码有问题,它执行网络抓取并将数据保存到 Access 数据库。对于这种情况,一切正常。当我将此数据库链接到 SharePoint 列表甚至 Dataverse 时,会出现问题,其中出现以下错误:
接口错误: ('IM002', '[IM002] [Microsoft][ODBC 驱动程序管理器] 找不到数据源名称且未指定默认驱动程序 (0) (SQLDriverConnect)')
import pandas as pd
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from datetime import datetime
import time
import threading
from sqlalchemy import create_engine
import pyodbc
#dsn = r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\Users\user\python\WSInterface.accdb;'
#dsn = 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\user\\python\\WSInterface.accdb;Persist Security Info=False;'
dsn = r'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\python\WSInterface.accdb;Persist Security Info=False;'
con = pyodbc.connect(dsn)
temp, combined_data, historic_data = get_data_and_classify()
cursor = con.cursor()
if not cursor.tables(table='Combine', tableType='TABLE').fetchone():
cursor.execute("""
CREATE TABLE Combine (
Data DATETIME,
Av1a6 INT);
""")
for index, row in combine_data.iterrows():
cursor.execute("""
INSERT INTO Combine (
Data, Av1a6
) VALUES (?, ?);
""",
row['Data'], row['Av1a6'])
if not cursor.tables(table='Historic', tableType='TABLE').fetchone():
cursor.execute("""
CREATE TABLE Historic (
Indice INT PRIMARY KEY NOT NULL,
Av1a6 INT
);
""")
for index, row in historic_data.iterrows():
cursor.execute("""
UPDATE Historic
SET Av1a6 = ?
WHERE Indice = ?;
""",
row['Av1a6'])
con.commit()
con.close()
我已经在计算机上安装了所有驱动程序,但问题仍然存在。有没有人对可能发生的事情有任何提示?
答: 暂无答案
评论