leginon-org / leginon-redmine-archive

1 stars 0 forks source link

sinedon querying to leginondb instead of appiondb #4275

Open leginonbot opened 3 months ago

leginonbot commented 3 months ago

Author Name: Neil Voss (@vosslab) Original Redmine Issue: 4275, https://emg.nysbc.org/redmine/issues/4275 Original Date: 2016-07-01


  File "/tank/software/myami-3.2/appion/bin/makestack2.py", line 1142, in postLoopFunctions
    apStackMeanPlot.makeStackMeanPlot(stackid)
  File "/tank/software/myami-3.2/appion/appionlib/apStackMeanPlot.py", line 53, in makeStackMeanPlot
    partdatas = sinedon.directq.complexMysqlQuery('appiondata',sqlcmd)
  File "/tank/software/myami-3.2/sinedon/directq.py", line 24, in complexMysqlQuery
    results = cur.selectall(query)
  File "/tank/software/myami-3.2/sinedon/sqldb.py", line 44, in selectall
    self.c.execute(strSQL, param)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1146, "Table 'leginondb.ApStackParticleData' doesn't exist")

Note it says 'leginondb.ApStackParticleData'

I checked the code and had it print the info:

sqlcmd = "SELECT " + \
 "particleNumber, mean, stdev " + \
 "FROM ApStackParticleData " + \
 "WHERE `REF|ApStackData|stack` = %i"%(stackid)
print sinedon.getConfig('appiondata')
partdatas = sinedon.directq.complexMysqlQuery(newdbname, sqlcmd)
{'passwd': 'xxxx', 'host': '127.0.0.1', 'db': 'ap9', 'user': 'usr_object'}
connecting

any ideas? this is the northwestern install using myami 3.2 under debian 8.

leginonbot commented 3 months ago

Original Redmine Comment Author Name: Neil Voss (@vosslab) Original Date: 2016-07-01T20:13:03Z


works using same server with myami 3.1

leginonbot commented 3 months ago

Original Redmine Comment Author Name: Anchi Cheng (@anchi2c) Original Date: 2016-07-02T00:22:59Z


Mayve the sql connection cursor got set to leginondb during force insert of ApStackParticleData some how that was not in the older version.

Can you try if adding something like this to sinedon directq.py getConnection function will help ?

dbname = param['db']
connections[modulename[.dbConnection.select_db(dbname)
return connections[modulename]
leginonbot commented 3 months ago

Original Redmine Comment Author Name: Neil Voss (@vosslab) Original Date: 2016-07-06T21:44:06Z


I was not sure how to implement the commands you have above, but I did this for a test case:

Appion v3.2

module load appion #v3.2
python
import sinedon
import sinedon.directq
from appionlib import apProject
newdbname = apProject.getAppionDBFromProjectId(1)
sinedon.setConfig('appiondata', db=newdbname)
sinedon.getConfig('appiondata')
sqlcmd = "SELECT particleNumber FROM ApStackParticleData LIMIT 10;"
results = sinedon.directq.complexMysqlQuery('appiondata',sqlcmd)

output:

>>> import sinedon
>>> import sinedon.directq
>>> from appionlib import apProject
>>> newdbname = apProject.getAppionDBFromProjectId(1)
>>> sinedon.setConfig('appiondata', db=newdbname)
{'passwd': 'xxxxx', 'host': '127.0.0.1', 'db': 'ap1', 'user': 'usr_object'}
>>> sinedon.getConfig('appiondata')
{'passwd': 'xxxxx', 'host': '127.0.0.1', 'db': 'ap1', 'user': 'usr_object'}
>>> sqlcmd = "SELECT particleNumber FROM ApStackParticleData LIMIT 10;"
>>> results = sinedon.directq.complexMysqlQuery('appiondata',sqlcmd)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tank/software/myami-3.2/sinedon/directq.py", line 24, in complexMysqlQuery
    results = cur.selectall(query)
  File "/tank/software/myami-3.2/sinedon/sqldb.py", line 44, in selectall
    self.c.execute(strSQL, param)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1146, "Table 'leginondb.ApStackParticleData' doesn't exist")

Appion 3.1 (also works with beta and trunk)

module load appion-3.1 #v3.1
python
import sinedon
import sinedon.directq
from appionlib import apProject
newdbname = apProject.getAppionDBFromProjectId(1)
sinedon.setConfig('appiondata', db=newdbname)
sinedon.getConfig('appiondata')
sqlcmd = "SELECT particleNumber FROM ApStackParticleData LIMIT 10;"
results = sinedon.directq.complexMysqlQuery('appiondata',sqlcmd)

output:

Python 2.7.9 (default, Mar  1 2015, 12:57:24) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sinedon
>>> import sinedon.directq
>>> from appionlib import apProject
>>> newdbname = apProject.getAppionDBFromProjectId(1)
>>> sinedon.setConfig('appiondata', db=newdbname)
{'passwd': 'xxxx', 'host': '127.0.0.1', 'db': 'ap1', 'user': 'usr_object'}
>>> sinedon.getConfig('appiondata')
{'passwd': 'xxxx', 'host': '127.0.0.1', 'db': 'ap1', 'user': 'usr_object'}
>>> sqlcmd = "SELECT particleNumber FROM ApStackParticleData LIMIT 10;"
>>> results = sinedon.directq.complexMysqlQuery('appiondata',sqlcmd)
connecting

I am not sure what makes Appion v3.2 so special as to fail, whereas 3.1, beta, and trunk all work.