|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
The project:
Make a db of a fictitious bank with its clients and accounts. The problem: 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. |
|
#2
|
|||
|
|||
|
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]). |
|
#3
|
||||
|
||||
|
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/...ySQL/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. Mark. |
|
#4
|
||||
|
||||
|
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.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Over my head with Python and MySQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|