使用pyodbc无法调用'str'对象

时间:2019-12-02 22:54:51

标签: database string file pyodbc

我不太了解为什么这不起作用。请帮助,如果您需要更多信息,请询问。预先谢谢你!

我在第16和17行上收到'str'对象的错误不可调用的错误。如何解决此问题?

# Import python odbc library
import pyodbc

# save output to .txt table
file = open('''E:\Gis Programming\Final Project\data\Python_Scripts\\Python_Output.txt''', "w")

file.write("mukey; pmkind; pmorigin; comppct_r; compname; majcompflag; \
    pmgroupname; SH_Val; CountRepeats; Weight_Calc; Percent_Sum; unique_mukey; \
    Weight_Final \n")

#connect to database
db_file = r'''E:\\Gis Programming\\Final Project\\data\\AL077\\soildb_US_2003.mdb'''
user = ''
password = ''
conn_str = 'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s;UID=%s;PWD=%s' \
                (db_file, user, password)
conn = pyodbc.connect(conn_str)
cursor = conn.cursor()

0 个答案:

没有答案