读取access中的数据
import concurrent.futures
import pandas as pd
import pandas.io.sql
import pyodbc
import accessdb
import pypyodbc as odbc
import matplotlib.pyplot as plt
import numpy as np
DBfile=r"\data\VWDB.accdb"
connection=pyodbc.connect(r"Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + DBfile + ";Uid=;Pwd=123;")
connection_cursor=connection.cursor()
sql = "SELECT * from MainTable;"
#通过list读取数据
connection_cursor.execute(sql)
all_data=connection_cursor.fetchall()#list
total_rows=len(all_data)#数据条数
total_cols=len(all_data[0])#数据列数
#通过DataFrame读取数据
df_temp=pandas.io.sql.read_sql(sql,connection)
connection_cursor.close()
connection.close()