Writing to a database with python, how to reference the DB?

 
Post new topic   Reply to topic    34SP.com Forum Index // Database Support
View previous topic :: View next topic  
Author Message
AdamDynamic
34SP Newbie
34SP Newbie


Joined: 11 Jul 2013
Posts: 3

PostPosted: Thu Jul 11, 2013 10:46 pm    Post subject: Writing to a database with python, how to reference the DB? Reply with quote
Hey,

I'm hoping someone here can help me? I have written a python script that populates a MySQL database and ran and tested it on 'localhost' (on my Ubuntu box). I want to migrate the script and database onto my 34sp hosting account and have the script run automatically every 20 mins (say).

I've set up a database on my hosting account with identical fields etc, I'm not sure how to do address the database when it is on my hosting account though? What do I need to replace 'localhost' with in my script?

Any help on this would be appreciated!

Thanks,

Adam
Back to top
View user's profile Send private message
peterwt
34SP User


Joined: 22 Mar 2001
Posts: 230
Location: South Wales

PostPosted: Fri Jul 12, 2013 10:40 am    Post subject: Reply with quote
Hi Adam,

I am not a Python user but I have used php to access a database on 34sp. You still use localhost to address a database located on your account.

I would guess you would use :-

db = MySQLdb.connect("localhost","username","password","databasename" )


Regards
_________________
Peter
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Post new topic   Reply to topic    34SP.com Forum Index // Database Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Powered by phpBB © 2001, 2002 phpBB Group