>>> hosts = InvManage.select(InvHost.name, InvIp.fqdn).join(InvHost).join(InvIp, on=(InvIp.device == InvHost.id)).group_by(InvHost.name).switch(InvManage).join(InvApplication).where(InvApplication.name == 'Solution Enabler')
>>> [h.name for h in hosts] Traceback (most recent call last):File "<stdin>", line 1, in <module>File ".../.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/peewee-2.0.7-py2.7.egg/peewee.py", line 1018, in nextinstance = self.iterate()File ".../.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/peewee-2.0.7-py2.7.egg/peewee.py", line 1006, in iteratereturn self.construct_instance(row)File ".../.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/peewee-2.0.7-py2.7.egg/peewee.py", line 965, in construct_instancereturn self.follow_joins(self.join_meta, collected_models, self.model)File ".../.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/peewee-2.0.7-py2.7.egg/peewee.py", line 968, in follow_joinsinst = collected_models[current]KeyError: <class 'ssp.db.InvManage'>
--
You received this message because you are subscribed to the Google Groups "peewee-orm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to peewee-orm+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
se_hosts = InvManage.select(InvManage, InvHost.name, InvIp.fqdn).join(InvHost).join(InvIp, on=(InvIp.device == InvHost.id)).group_by(InvHost.name).switch(InvManage).join(InvApplication).where(InvApplication.name == 'Solution Enabler')>>> se_hosts.count()1L>>> [h.name for h in se_hosts]
Traceback (most recent call last):File "<stdin>", line 1, in <module>
AttributeError: 'InvManage' object has no attribute 'name'>>>
>>> se_hosts = InvManage.select(InvManage, InvHost.name.alias('hostname'), InvIp.fqdn).join(InvHost).join(InvIp, on=(InvIp.device == InvHost.id)).group_by(InvHost.name).switch(InvManage).join(InvApplication).where(InvApplication.name == 'Solution Enabler')>>> [h.name for h in se_hosts]
Traceback (most recent call last):File "<stdin>", line 1, in <module>
File ".../.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/peewee-2.0.7-py2.7.egg/peewee.py", line 1387, in __iter__return iter(self.execute())File ".../.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/peewee-2.0.7-py2.7.egg/peewee.py", line 1380, in executeself._qr = QueryResultWrapper(self.model_class, self._execute(), query_meta)File ".../.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/peewee-2.0.7-py2.7.egg/peewee.py", line 1177, in _executereturn self.database.execute_sql(sql, params, self.require_commit)File ".../.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/peewee-2.0.7-py2.7.egg/peewee.py", line 1545, in execute_sqlres = cursor.execute(sql, params or ())File ".../.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/MySQLdb/cursors.py", line 201, in executeself.errorhandler(self, exc, value)File ".../.pythonbrew/pythons/Python-2.7.2/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandlerraise errorclass, errorvalue_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS hostname' at line 1")
>>> se_hosts.sql<bound method SelectQuery.sql of <class 'ssp.db.InvManage'> SELECT t1.`id`, t1.`app_status`, t1.`application_id`, t1.`comment`, t1.`device_class`, t1.`device_id`, t1.`host_id`, t1.`preference`, t2.`name` AS hostname, t3.`fqdn` FROM `inv_manage` AS t1 INNER JOIN `inv_host` AS t2 ON (t1.`host_id` = t2.`id`) INNER JOIN `inv_application` AS t4 ON (t1.`application_id` = t4.`id`) INNER JOIN `inv_ip` AS t3 ON (t2.`id` = t3.`device_id`) WHERE (t4.`name` = %s) GROUP BY t2.`name` AS hostname [u'Solution Enabler']>
>>> se_hosts.sql<bound method SelectQuery.sql of <class 'ssp.db.InvManage'> SELECT t1.`id`, t1.`app_status`, t1.`application_id`, t1.`comment`, t1.`device_class`, t1.`device_id`, t1.`host_id`, t1.`preference`, t2.`name` AS hostname, t3.`fqdn` FROM `inv_manage` AS t1 INNER JOIN `inv_host` AS t2 ON (t1.`host_id` = t2.`id`) INNER JOIN `inv_application` AS t4 ON (t1.`application_id` = t4.`id`) INNER JOIN `inv_ip` AS t3 ON (t2.`id` = t3.`device_id`) WHERE (t4.`name` = %s) GROUP BY t2.`name` AS hostname [u'Solution Enabler']>