December 2nd, 2003, 10:18 PM
Over my head with Python and MySQL
Make a db of a fictitious bank with its clients and accounts.
Taking the cleaned data (all in one text file) and putting it into the db using python. The hard part isn't inserting directly into the db, but some parts of the client table that i need to populate require keys from other tables... not sure how to go about getting that (ie taking column 6 of the text file and using it to find the referential key in the street table, then submitting the key in place of the streets name).
If someone could help, would be a great relief.
December 3rd, 2003, 12:45 PM
I've never used Python w/ MySQL before, but I have used Python to load an Oracle database (using cx_Oracle). The process was pretty simple-- if you've got a text file that contains values that correspond to keys from other tables, just write the code that does a select to retrieve the values from the table befre you do your insert. Python was quick enough to populate the oracle database with tens of thousands of records (one table had 19,000 records alone) in a reasonable amount of time (15 minutes IIRC?).
If you don't want to do the data lookups individually, you can just do a select * from the table(s) that have the data you'll be using, put that data into a dictionary, and then do lookups on the dictionary as you need to (mydict[key_from_text_file]).
December 3rd, 2003, 05:18 PM
I read this earlier but i couldn't deside if this was homework or not? Anyway if you're new to MySQL and Python i'd start by reading http://www.devshed.com/Server_Side/P...SQL/page1.html
Also if you could attach a sample of the file your wanting to insert into MySQL that could be very helpful. Obviously the file's gonna have to go under the knife before we can do this.
December 3rd, 2003, 05:46 PM
Also have a read of the MySQL docs at http://www.mysql.com/doc to work out how you will do this in terms of MySQL queries, and use the MySQL board in this forum to discuss that aspect of the problem.