If anyone can help with the python script
My output is list format which I need to insert into ms access. I achieve the list from the below python script.
import csv
import urllib
import pandas as pd
from sqlalchemy import create_engine
FILE = 'Sample.csv'
def finance_manager(file):
sum = 0
transactions = []
with open(file, mode='r') as csv_file:
csv_reader = csv.reader(csv_file)
header = next(csv_reader)
for row in csv_reader:
# get name, amount, currency
name = row[1]
amount = float(row[3])
date = row[2]
transaction = (name, date, amount)
sum += amount
transactions.append(transaction)
print(f"The sum of your transactions this month is {sum}")
print(' ')
return transactions
print(finance_manager(FILE))
access_string =(
r"DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};"
r"DBQ= C:\Users\User1\Documents\DatabaseSample.accdb")
cnnurl = "access+pyodbc:///?odbc_connect={urllib.parse.quote_plus(access_string)}"
acc_engine = create_engine(cnnurl)
The result list :
print(finance_manager(FILE))

I suggest working the other way round: From Access, you can easily establish a connection to a csv-file. You already have your Sample.csv, so let a (temporary) table in Access point to this file. Right-mouse-click -> Import -> Textfile -> Then select the file and last option to connect. In Access, you could perform the next steps, like copying the data into a destination-table. (E.g. call a Query from python) So you can reuse Sample.csv without losing data.