1

For a school project I am to write and organize a set of data to a Microsoft Access database file. I am fairly comfortable with using python to read and write to files but can't find any information online regarding what I am specifically looking for.

I want to know what i would need to do to write to a database in specific Columns and Tables, for example, write the variable "name" in a field called "name" instead of just randomly adding it to the database.

EDIT: I cannot use any additional packages when doing this.

1 Answer 1

2

You can use PyODBC. Here is an example.

Edit: "no extra modules" is nice but unless you want to re-write pyodbc from scratch you may as well just use it.

Edit2: if you want to know what that would look like, check out pypyodbc - a pure-python odbc driver in about 3000 lines of Python code.

Sign up to request clarification or add additional context in comments.

2 Comments

I am not allowed to actually implement separate modules into the program, is there no way to do it without or would simply writing like you would to a normal file (file.write(...)) work?
@Zunea: I would suggest getting the pypyodbc source code and copying over just the minimum bits your code needs to work (keep borrowed code in a separate section and attribute it properly, though!).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.