Reading and writing access database table in python

后端 未结 1 1592
执念已碎
执念已碎 2021-01-16 22:11

I have an access database. Inside are a few tables I created. I want to use python to read through one of the tables and make a list of everything in a column. I want to com

相关标签:
1条回答
  • 2021-01-16 22:25

    You can convert the table to csv so you can open it with excel

    Try this:

        import csv
    
    roomnumber = 0.00
    roomname = 0.00
    lueftungList = []
    
    import time
    
    class Lueftung:
    
        def getData(self):
            global roomnumber
            global roomname
    
    
            roomnumber = input("roomnumber: ")
            roomname = input("roomname  : ")
    
    
    
        myFormattedList = [ '%.2f' % elem for elem in lueftungList ]
    
    
    
        def main(self):
            global roomnumber
            global roomname
    
    
    
        lueftungList.append(["", roomnumber, roomname, "", ""])
    
    
        lueftungList.insert(0,[(time.strftime("%d.%m.%Y")), "roomnumber", "roomname",])
    
    
        # convert to csv
        with open("lueftung.csv", "w", newline="") as csvfile:
            cwriter = csv.writer(csvfile, delimiter=";")
            for row in lueftungList:
                cwriter.writerow(row)
    
    
    if __name__ == "__main__":
        luft = Lueftung()
        luft.main()
    
    0 讨论(0)
提交回复
热议问题