From: Massi on 9 Jul 2010 11:07 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_password(a)phpmyadmin.myhost.com/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!
From: Rebelo on 9 Jul 2010 12:20 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(a)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
|
Pages: 1 Prev: Netbeans plugin and Python 3 Next: Last day to submit your Surge 2010 CFP! |