Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 2nd, 2003, 09:18 PM
Scabs Scabs is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 1 Scabs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Over my head with Python and MySQL

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.

Reply With Quote
  #2  
Old December 3rd, 2003, 11:45 AM
oxygenthief oxygenthief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 35 oxygenthief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 10
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]).

Reply With Quote
  #3  
Old December 3rd, 2003, 04:18 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 68
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #4  
Old December 3rd, 2003, 04:46 PM
telex4's Avatar
telex4 telex4 is offline
Wacky hack
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2001
Location: London, England
Posts: 513 telex4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 38 m 37 sec
Reputation Power: 13
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Over my head with Python and MySQL

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap