SqlAlchemy: remote connection on problem on mysql database

M

Massi

Hi everyone,

in my script I'm trying to connect to a remote database using
sqlalchemy. Since I'm pretty new to this library I'm not really sure
of what I am doing :). Up to now what I'm doing to connect to the
database is this:

engine = create_engine("mysql://
my_username:[email protected]/my_db_name")
metadata = MetaData(engine, reflect=True)

If I run this script I get the following error:

Traceback (most recent call last):
File "C:\Documents and Settings\pc2\Desktop\prova.py", line 9, in
<module>
metadata = MetaData(engine, reflect=True)
File "C:\Python25\lib\site-packages\sqlalchemy-0.6.0-py2.5.egg
\sqlalchemy\schema.py", line 1770, in __init__
self.reflect()
File "C:\Python25\lib\site-packages\sqlalchemy-0.6.0-py2.5.egg
\sqlalchemy\schema.py", line 1879, in reflect
connection=conn))
File "c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\engine\base.py", line 1604, in table_names
conn = self.contextual_connect()
File "c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\engine\base.py", line 1592, in contextual_connect
return self.Connection(self, self.pool.connect(),
close_with_result=close_with_result, **kwargs)
File "c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py", line 154, in connect
return _ConnectionFairy(self).checkout()
File "c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py", line 318, in __init__
rec = self._connection_record = pool.get()
File "c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py", line 173, in get
return self.do_get()
File "c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py", line 665, in do_get
con = self.create_connection()
File "c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py", line 134, in create_connection
return _ConnectionRecord(self)
File "c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py", line 209, in __init__
self.connection = self.__connect()
File "c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py", line 271, in __connect
connection = self.__pool._creator()
File "c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\engine\strategies.py", line 76, in connect
return dialect.connect(*cargs, **cparams)
File "c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\engine\default.py", line 227, in connect
return self.dbapi.connect(*cargs, **cparams)
File "C:\Python25\lib\site-packages\MySQLdb\__init__.py", line 74,
in Connect
return Connection(*args, **kwargs)
File "C:\Python25\lib\site-packages\MySQLdb\connections.py", line
170, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (OperationalError) (2003, "Can't connect to MySQL
server on 'phpmyadmin.myhost.com' (10060)") None None

Is there something I am missing? thanks in advance for the help!
 
R

Rebelo

from SQLAlchemy docs (http://www.sqlalchemy.org/docs/
dbengine.html#database-engine-options):
"
create_engine() URL Arguments

SQLAlchemy indicates the source of an Engine strictly via RFC-1738
style URLs, combined with optional keyword arguments to specify
options for the Engine. The form of the URL is:

dialect+driver://username:password@host:port/database
Dialect names include the identifying name of the SQLAlchemy dialect
which include sqlite, mysql, postgresql, oracle, mssql, and firebird.
The drivername is the name of the DBAPI to be used to connect to the
database using all lowercase letters. If not specified, a “default”
DBAPI will be imported if available - this default is typically the
most widely known driver available for that backend (i.e. cx_oracle,
pysqlite/sqlite3, psycopg2, mysqldb).
"

are you sure that phpmyadmin.myhost.com is your mysql server?
or are you missing port? usually its 3306. AFAIK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top