Thread: [SQLObject] Problems with sqlObject-Mysql Remote connection
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Felix <fel...@te...> - 2006-03-29 22:01:13
|
Hi everyone !!! This appears so strange ... the following code works in local but not on remotely. I've trusted that the remote server works, the user/pass are right, and even a little sqlobject-code works on remote, like this: #This works on local and on remote, passing the correct connectionForURI from sqlobject import * sqlhub.processConnection = connectionForURI('mysql://***:***@***/***') class aTable(SQLObject): class sqlmeta: table = 'aRealRemoteTable' fromDatabase = True for item in aTable.select(): print item.id So, i'm sure the errors are in my code. When i run it, it hangs. I tried to insert several prints 'hello' around the code to determine the exact point of the hang. I've discovered that the hangs comes after the declaration of the table-class at makeTable() method. import sqlobject import sys, os, string, MySQLdb class connectionHandler: def __init__(self, user, password, host, db): self.user = user self.password = password self.host = host self.db = db def makeConnection(self): try: self.conn = sqlobject.connectionForURI('mysql://'+self.user+':'+self.password+'@'+self.host+'/'+self.db) except MySQLdb.Error, e: return e return 0 def makeTable(self, theTableName): try: class RemoteTable(sqlobject.SQLObject): _connection = self.conn _connection.debug = True class sqlmeta: table = theTableName fromDatabase = True #This is the exact point of the hang-up. The print below dont work never print 'Here is the hang !!!, WHY !!!' except MySQLdb.Error, e: return(0, e) return(RemoteTable, 0) if __name__ == '__main__': conn = connectionHandler('aRemoteUser','aRemotePass','aRemoteHost','aRemoteDB') error = conn.makeConnection() if error <> 0: print "Except: Can't connect %s" % error sys.exit(1) (myTable,error) = conn.makeTable('prueba') if error <> 0: print "Except: Can't Create %s " % error sys.exit(1) for item in myTable.select(): print item.id |
From: Felix <fel...@te...> - 2006-03-29 22:09:49
|
I've forgoted. When the hang-up happens if i do ctrl+c the traceback dump says: Traceback (most recent call last): File "conexionBD21.py", line 43, in ? (myTable,error) = conn.makeTable('prueba') File "conexionBD21.py", line 21, in makeTable class RemoteTable(sqlobject.SQLObject): File "/usr/lib/python2.3/site-packages/SQLObject-0.7.0-py2.3.egg/sqlobject/declarative.py", line 94, in __new__ cls.__classinit__(cls, new_attrs) File "/usr/lib/python2.3/site-packages/SQLObject-0.7.0-py2.3.egg/sqlobject/main.py", line 770, in __classinit__ cls.sqlmeta.addColumnsFromDatabase() File "/usr/lib/python2.3/site-packages/SQLObject-0.7.0-py2.3.egg/sqlobject/main.py", line 421, in addColumnsFromDatabase for columnDef in conn.columnsFromSchema(sqlmeta.table, soClass): File "/usr/lib/python2.3/site-packages/SQLObject-0.7.0-py2.3.egg/sqlobject/mysql/mysqlconnection.py", line 124, in columnsFromSchema colData = self.queryAll("SHOW COLUMNS FROM %s" File "/usr/lib/python2.3/site-packages/SQLObject-0.7.0-py2.3.egg/sqlobject/dbconnection.py", line 316, in queryAll return self._runWithConnection(self._queryAll, s) File "/usr/lib/python2.3/site-packages/SQLObject-0.7.0-py2.3.egg/sqlobject/dbconnection.py", line 215, in _runWithConnection conn = self.getConnection() File "/usr/lib/python2.3/site-packages/SQLObject-0.7.0-py2.3.egg/sqlobject/dbconnection.py", line 226, in getConnection conn = self.makeConnection() File "/usr/lib/python2.3/site-packages/SQLObject-0.7.0-py2.3.egg/sqlobject/mysql/mysqlconnection.py", line 41, in makeConnection db=self.db, user=self.user, passwd=self.password, **self.kw) KeyboardInterrupt Maybe it'll help. Thanks |
From: Oleg B. <ph...@ma...> - 2006-03-29 22:13:52
|
On Thu, Mar 30, 2006 at 12:01:00AM +0200, Felix wrote: > class RemoteTable(sqlobject.SQLObject): > _connection = self.conn > _connection.debug = True > class sqlmeta: > table = theTableName > fromDatabase = True > #This is the exact point of the hang-up. The print below dont work never > print 'Here is the hang !!!, WHY !!!' SQLObject is trying to connecto to the server and get the table's description. If it hangs it it's probably becuase of network problems. Can you connect to the server and run a query using a commandline tools (mysql, mysqladmin)? Can you connect using MySQLdb python DB API driver? Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Felix <fel...@te...> - 2006-03-29 22:33:43
|
Yes Oleg !! i can connect the remote server via mysql-client, mysqldb python db api and throug little sqlobject-code like: #This code works on the remote server from sqlobject import * sqlhub.processConnection = connectionForURI('mysql://***:***@***/***') class aTable(SQLObject): class sqlmeta: table = 'aRealRemoteTable' fromDatabase = True for item in aTable.select(): print item.id I've realized that the other code was so extense ... check that easy code below instead, it hags exactly in the same point and the traceback after ctrl+c it's the same. It works perfectly on local, but hangs on remote: import sqlobject import sys, os, string, MySQLdb class connectionHandler: def doTable(self): self.conn = sqlobject.connectionForURI('mysql://***:***@***/***') class RemoteTable(sqlobject.SQLObject): _connection = self.conn _connection.debug = True #This print shows 'a' on stdout print 'a' class sqlmeta: table = 'prueba' fromDatabase = True #This print shows 'c' on stdout print 'c' #This print is never showed, and hang-up print 'b' return RemoteTable if __name__ == '__main__': myTable = connectionHandler().doTable() for item in myTable.select(): print item.id Thanks again Oleg, thanks a lot On Thu, 30 Mar 2006 02:13:37 +0400 Oleg Broytmann <ph...@ma...> wrote: > On Thu, Mar 30, 2006 at 12:01:00AM +0200, Felix wrote: > > class RemoteTable(sqlobject.SQLObject): > > _connection = self.conn > > _connection.debug = True > > class sqlmeta: > > table = theTableName > > fromDatabase = True > > #This is the exact point of the hang-up. The print below dont work never > > print 'Here is the hang !!!, WHY !!!' > > SQLObject is trying to connecto to the server and get the table's > description. If it hangs it it's probably becuase of network problems. > Can you connect to the server and run a query using a commandline tools > (mysql, mysqladmin)? Can you connect using MySQLdb python DB API driver? > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss |
From: Felix <fel...@te...> - 2006-03-29 22:41:10
|
Hmmm ... i was so impatient... sorry but the following code is posted you before works... so slow but works.. import sqlobject import sys, os, string, MySQLdb class connectionHandler: def doTable(self): self.conn = sqlobject.connectionForURI('mysql://***:***@***/***') class RemoteTable(sqlobject.SQLObject): _connection = self.conn _connection.debug = True #This print shows 'a' on stdout print 'a' class sqlmeta: table = 'prueba' fromDatabase = True #This print shows 'c' on stdout print 'c' #This print is never showed, and hang-up print 'b' return RemoteTable if __name__ == '__main__': myTable = connectionHandler().doTable() for item in myTable.select(): print item.id So, my problem was in the initial extense code. I really don't know 'cause it hangs on getting the remote table description... Trust me, it's not a network problem |
From: Oleg B. <ph...@ma...> - 2006-03-29 22:47:17
|
On Thu, Mar 30, 2006 at 12:40:49AM +0200, Felix wrote: > Trust me, it's not a network problem Then I'm puzzled as much as you. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |