|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
I tried to get access to a MySQL database like this:
import MySQLdb db = MySQLdb.connect(db = 'mydb', user = 'user', passwd = 'password') I get this error: Traceback (most recent call last): File "Myfile.py", line 3, in ? db = MySQLdb.connect(db = 'mydb', user = 'user', passwd = 'password') File "/usr/local/lib/python1.6/site-packages/MySQLdb.py", line 457, in __init__ i = map(int, split(split(self._server_info, '-')[0], '.')) ValueError: invalid literal for int(): 26a What is wrong? |
|
#2
|
|||
|
|||
|
I don't know much Python, and any database work I've done has been with Perl. However, it doesn't look like you specified a host name as an argument in your connect.
In Perl with DBI the connect would look like: Code:
$dbh = DBI->connect( "DBI:mysql:database:hostname", "user", "pass", {additional arg} );
In this connect a hostname would always have to be specified, even if its just 'localhost'. Hope this helps.
__________________
- dsb - ![]() Perl Guy |
|
#3
|
|||
|
|||
|
You are forgetting one important thing:
Where is host information you want to connect? |
|
#4
|
|||
|
|||
|
The problem is already solved. For your information:
You don't need to specify a host if the DB and the script are on the same machine("local host"). |
|
#5
|
|||
|
|||
|
You Right, Since it is the default value.
I tough you connect to it from different machine (?) |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Access to a MySQL database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|