SqlAlchemy: remote connection on problem on mysql database

Discussion in 'Python' started by Massi, Jul 9, 2010.

  1. Massi

    Massi Guest

    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:/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!
    Massi, Jul 9, 2010
    #1
    1. Advertising

  2. Massi

    Rebelo Guest

    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
    Rebelo, Jul 9, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sudsy
    Replies:
    1
    Views:
    454
    Keith Wansbrough
    Aug 16, 2004
  2. sylvian

    SQLAlchemy problem : /

    sylvian, Aug 31, 2006, in forum: Python
    Replies:
    0
    Views:
    293
    sylvian
    Aug 31, 2006
  3. Jacques

    remote MySQL connection

    Jacques, Mar 13, 2005, in forum: Ruby
    Replies:
    0
    Views:
    87
    Jacques
    Mar 13, 2005
  4. Replies:
    5
    Views:
    302
    Xho Jingleheimerschmidt
    Mar 7, 2009
  5. Nick Sabalausky
    Replies:
    3
    Views:
    204
    Nick Sabalausky
    Oct 24, 2012
Loading...

Share This Page