Code

Opened 4 years ago

Closed 4 years ago

#13712 closed (duplicate)

raw() sql bug in Python 2.5.2

Reported by: Renskers Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords: raw sql iterate
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I am using the Model.objects.raw() function to write my own custom query. This works perfect on my local machine (Python 2.6.1) but it does not work on the server (Python 2.5.2).

Creating the raw query set works fine, but as soon as I want to iterate over it, I get this error:

__init__() keywords must be strings

Traceback:

Environment:

Request Method: GET
Request URL: http://biobench-acc.gw20e.com:8000/benchmark/
Django Version: 1.2.1 SVN-545
Python Version: 2.5.2
Installed Applications:
['django.contrib.sites',
 'django.contrib.auth',
 'django.contrib.admin',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.humanize',
 'django.contrib.gis',
 'django.contrib.messages',
 'cms',
 'cms.plugins.text',
 'cms.plugins.picture',
 'cms.plugins.link',
 'cms.plugins.file',
 'cms.plugins.googlemap',
 'cms.plugins.video',
 'cms.plugins.twitter',
 'cms.plugins.snippet',
 'mptt',
 'publisher',
 'menus',
 'reversion',
 'compressor',
 'django_extensions',
 'biobench',
 'analytics',
 'journal',
 'help',
 'account',
 'south',
 'GChartWrapper.charts',
 'devserver',
 'debug_toolbar']
Installed Middleware:
('django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'cms.middleware.multilingual.MultilingualURLMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'cms.middleware.page.CurrentPageMiddleware',
 'cms.middleware.user.CurrentUserMiddleware',
 'cms.middleware.toolbar.ToolbarMiddleware',
 'cms.middleware.media.PlaceholderMediaMiddleware',
 'biobench.middleware.CacheAccount',
 'debug_toolbar.middleware.DebugToolbarMiddleware')


Traceback:
File "packages/django/core/handlers/base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "packages/django/contrib/auth/decorators.py" in _wrapped_view
  25.                 return view_func(request, *args, **kwargs)
File "/opt/APPS/biobench/acc/Biobench/benchmark/views.py" in index
  48.     for result in results:
File "packages/django/db/models/query.py" in __iter__
  1,373.             yield self.transform_results(row)
File "packages/django/db/models/query.py" in transform_results
  1,462.         instance = model_cls(**model_init_kwargs)

Exception Type: TypeError at /benchmark/
Exception Value: __init__() keywords must be strings

And the variable model_init_kwargs holds at that moment this giant dictionary:

{'datetime': datetime.datetime(2008, 1, 1, 12, 0), u'digestate_digestate_volume_flow_measured': 0.0, u'digestate_digestate_volume_flow_measured_monthly_average': 0.0, u'digestate_digestate_volume_flow_measured_moving_average': 0.0, u'digestate_digestate_volume_flow_measured_weekly_average': 0.0, u'digestate_digestate_volume_flow_metered': 0.0, u'digestate_n_calculated': 5224.0646525267703, u'digestate_n_calculated_monthly_average': 5279.4801748385298, u'digestate_n_calculated_moving_average': 5224.0646525267703, u'digestate_n_calculated_weekly_average': 5221.38703388874, u'digestate_organic_dry_substance_calculated': 0.0, u'digestate_organic_dry_substance_calculated_monthly_average': 0.0, u'digestate_organic_dry_substance_calculated_moving_average': 0.0, u'digestate_organic_dry_substance_calculated_weekly_average': 0.0, u'digestate_phosphate_calculated': 60.630099999999999, u'digestate_phosphate_calculated_monthly_average': 55.562560854524499, u'digestate_phosphate_calculated_moving_average': 60.630099999999999, u'digestate_phosphate_calculated_weekly_average': 60.656231899037302, u'digester_biogas_volumetric_production_calculated': 3.7604754910504199, u'digester_biogas_volumetric_production_calculated_monthly_average': 3.3999011782886801, u'digester_biogas_volumetric_production_calculated_moving_average': 3.7604754910504199, u'digester_biogas_volumetric_production_calculated_weekly_average': 3.7617951104039, u'digester_residence_time_calculated': 34.099433949396399, u'digester_residence_time_calculated_monthly_average': 37.836838019052699, u'digester_residence_time_calculated_moving_average': 34.099433949396399, u'digester_residence_time_calculated_weekly_average': 34.068200938916704, u'digester_specific_biogas_production_calculated': 717.99370022062499, u'digester_specific_biogas_production_calculated_monthly_average': 714.25075433089398, u'digester_specific_biogas_production_calculated_moving_average': 717.99370022062499, u'digester_specific_biogas_production_calculated_weekly_average': 717.97007095378603, u'digester_specific_power_production_calculated': 7.6553196090158098, u'digester_specific_power_production_calculated_monthly_average': 7.4480614474277802, u'digester_specific_power_production_calculated_moving_average': 7.6553196090158098, u'digester_specific_power_production_calculated_weekly_average': 8.1261211308269807, u'digester_temperature_measured': 41.5, u'digester_temperature_measured_monthly_average': 41.052258064516103, u'digester_temperature_measured_moving_average': 41.5, u'digester_temperature_measured_weekly_average': 41.362000000000002, u'digester_volumetric_load_calculated': 5.2374770000000002, u'digester_volumetric_load_calculated_monthly_average': 4.75731470967742, u'digester_volumetric_load_calculated_moving_average': 5.2374770000000002, u'digester_volumetric_load_calculated_weekly_average': 5.2394841999999997, u'gas_analysis_biogas_volume_flow_calculated': 3760.4754910504198, u'gas_analysis_biogas_volume_flow_calculated_monthly_average': 3399.9011782886801, u'gas_analysis_biogas_volume_flow_calculated_moving_average': 3760.4754910504198, u'gas_analysis_biogas_volume_flow_calculated_weekly_average': 3761.7951104038998, u'gas_analysis_biogas_volume_flow_measured': 0.0, u'gas_analysis_biogas_volume_flow_measured_monthly_average': 2630.3277419354799, u'gas_analysis_biogas_volume_flow_measured_moving_average': 0.0, u'gas_analysis_biogas_volume_flow_measured_weekly_average': 2451.4879999999998, u'gas_analysis_biogas_volume_flow_metered': 3221.0, u'gas_analysis_ch4_calculated': 47.911955261542701, u'gas_analysis_ch4_calculated_monthly_average': 50.139126956355, u'gas_analysis_ch4_calculated_moving_average': 47.911955261542701, u'gas_analysis_ch4_calculated_weekly_average': 47.902063417719397, u'gas_analysis_ch4_measured': 50.0, u'gas_analysis_ch4_measured_monthly_average': 49.451612903225801, u'gas_analysis_ch4_measured_moving_average': 50.0, u'gas_analysis_ch4_measured_weekly_average': 49.200000000000003, u'gas_analysis_ch4_volume_flow_calculated': 2016.9503574, u'gas_analysis_ch4_volume_flow_calculated_monthly_average': 1824.8534909354801, u'gas_analysis_ch4_volume_flow_calculated_moving_average': 2016.9503574, u'gas_analysis_ch4_volume_flow_calculated_weekly_average': 2017.65803228, u'gas_analysis_ch4_volume_flow_measured': 0.0, u'gas_analysis_ch4_volume_flow_measured_monthly_average': 1299.6940387096799, u'gas_analysis_ch4_volume_flow_measured_moving_average': 0.0, u'gas_analysis_ch4_volume_flow_measured_weekly_average': 1201.22912, u'gas_analysis_co2_calculated': 52.088044738457299, u'gas_analysis_co2_calculated_monthly_average': 49.860873043645, u'gas_analysis_co2_calculated_moving_average': 52.088044738457299, u'gas_analysis_co2_calculated_weekly_average': 52.097936582280603, u'gas_analysis_co2_measured': 50.0, u'gas_analysis_co2_measured_monthly_average': 50.548387096774199, u'gas_analysis_co2_measured_moving_average': 50.0, u'gas_analysis_co2_measured_weekly_average': 50.799999999999997, u'gas_analysis_firing_thermal_capacity_calculated': 18715.282366314601, u'gas_analysis_firing_thermal_capacity_calculated_monthly_average': 16932.815542390399, u'gas_analysis_firing_thermal_capacity_calculated_moving_average': 18715.282366314601, u'gas_analysis_firing_thermal_capacity_calculated_weekly_average': 18721.848881526101, u'gas_analysis_firing_thermal_capacity_measured': 0.0, u'gas_analysis_firing_thermal_capacity_measured_monthly_average': 12059.860985187101, u'gas_analysis_firing_thermal_capacity_measured_moving_average': 0.0, u'gas_analysis_firing_thermal_capacity_measured_weekly_average': 11146.20500448, u'gas_analysis_h2s_measured': 220.0, u'gas_analysis_h2s_measured_monthly_average': 217.09677419354799, u'gas_analysis_h2s_measured_moving_average': 220.0, u'gas_analysis_h2s_measured_weekly_average': 222.40000000000001, u'gas_analysis_o2_measured': 0.59999999999999998, u'gas_analysis_o2_measured_monthly_average': 0.65806451612903205, u'gas_analysis_o2_measured_moving_average': 0.59999999999999998, u'gas_analysis_o2_measured_weekly_average': 0.54000000000000004, u'gas_analysis_power_calculated': 318.97165037565901, u'gas_analysis_power_calculated_monthly_average': 310.33589364282398, u'gas_analysis_power_calculated_moving_average': 318.97165037565901, u'gas_analysis_power_calculated_weekly_average': 338.58838045112498, u'gas_usage_added_pilot_energy_calculated': 0.0, u'gas_usage_added_pilot_energy_calculated_monthly_average': 1275.77406451613, u'gas_usage_added_pilot_energy_calculated_moving_average': 0.0, u'gas_usage_added_pilot_energy_calculated_weekly_average': 1144.4218000000001, u'gas_usage_efficiency_calculated': 40.904109589041099, u'gas_usage_efficiency_calculated_monthly_average': 40.904109589041099, u'gas_usage_efficiency_calculated_moving_average': 40.904109589041099, u'gas_usage_efficiency_calculated_weekly_average': 40.904109589041099, u'gas_usage_efficiency_measured': 0.0, u'gas_usage_efficiency_measured_monthly_average': 32.069806325895399, u'gas_usage_efficiency_measured_moving_average': 0.0, u'gas_usage_efficiency_measured_weekly_average': 26.673639691338799, u'gas_usage_green_gas_to_network_measured': 0.0, u'gas_usage_green_gas_to_network_measured_monthly_average': 0.0, u'gas_usage_green_gas_to_network_measured_moving_average': 0.0, u'gas_usage_green_gas_to_network_measured_weekly_average': 0.0, u'gas_usage_green_gas_to_network_metered': 0.0, u'gas_usage_heating_oil_measured': 0.0, u'gas_usage_heating_oil_measured_monthly_average': 128.64516129032299, u'gas_usage_heating_oil_measured_moving_average': 0.0, u'gas_usage_heating_oil_measured_weekly_average': 115.40000000000001, u'gas_usage_heating_oil_metered': 161.0, u'gas_usage_pilot_fuel_consumption_calculated': 0.0, u'gas_usage_pilot_fuel_consumption_calculated_monthly_average': 7.62158605509038, u'gas_usage_pilot_fuel_consumption_calculated_moving_average': 0.0, u'gas_usage_pilot_fuel_consumption_calculated_weekly_average': 6.1122970170795696, u'gas_usage_pilot_fuel_consumption_measured': 0.0, u'gas_usage_pilot_fuel_consumption_measured_monthly_average': 10.306701505443399, u'gas_usage_pilot_fuel_consumption_measured_moving_average': 0.0, u'gas_usage_pilot_fuel_consumption_measured_weekly_average': 8.2105632915091196, u'gas_usage_power_consumption_measured': 0.0, u'gas_usage_power_consumption_measured_monthly_average': 0.0, u'gas_usage_power_consumption_measured_moving_average': 0.0, u'gas_usage_power_consumption_measured_weekly_average': 0.0, u'gas_usage_power_consumption_metered': 0.0, u'gas_usage_power_production_calculated': 7655.3196090158099, u'gas_usage_power_production_calculated_monthly_average': 7448.06144742778, u'gas_usage_power_production_calculated_moving_average': 7655.3196090158099, u'gas_usage_power_production_calculated_weekly_average': 8126.1211308269903, u'gas_usage_power_production_measured': 0.0, u'gas_usage_power_production_measured_monthly_average': 5819.6129032258104, u'gas_usage_power_production_measured_moving_average': 0.0, u'gas_usage_power_production_measured_weekly_average': 5376.1999999999998, u'gas_usage_power_production_metered': 6034.0, u'gas_usage_rapeseed_methyl_ester_measured': 0.0, u'gas_usage_rapeseed_methyl_ester_measured_monthly_average': 0.0, u'gas_usage_rapeseed_methyl_ester_measured_moving_average': 0.0, u'gas_usage_rapeseed_methyl_ester_measured_weekly_average': 0.0, u'gas_usage_rapeseed_methyl_ester_metered': 0.0, u'gas_usage_rapeseed_oil_measured': 0.0, u'gas_usage_rapeseed_oil_measured_monthly_average': 0.0, u'gas_usage_rapeseed_oil_measured_moving_average': 0.0, u'gas_usage_rapeseed_oil_measured_weekly_average': 0.0, u'gas_usage_rapeseed_oil_metered': 0.0, 'id': 2L, 'plant_id': 6L, u'substrate_flow_dry_substance_calculated': 5616.6599999999999, u'substrate_flow_dry_substance_calculated_monthly_average': 5084.1077419354797, u'substrate_flow_dry_substance_calculated_moving_average': 5616.6599999999999, u'substrate_flow_dry_substance_calculated_weekly_average': 5618.3879999999999, u'substrate_flow_k2o_calculated': 85.179500000000004, u'substrate_flow_k2o_calculated_monthly_average': 79.527887871693494, u'substrate_flow_k2o_calculated_moving_average': 85.179500000000004, u'substrate_flow_k2o_calculated_weekly_average': 85.240453126233803, u'substrate_flow_n_calculated': 153.20092, u'substrate_flow_n_calculated_monthly_average': 141.11730950671301, u'substrate_flow_n_calculated_moving_average': 153.20092, u'substrate_flow_n_calculated_weekly_average': 153.263461225686, u'substrate_flow_organic_dry_substance_calculated': 5237.4769999999999, u'substrate_flow_organic_dry_substance_calculated_monthly_average': 4757.3147096774201, u'substrate_flow_organic_dry_substance_calculated_moving_average': 5237.4769999999999, u'substrate_flow_organic_dry_substance_calculated_weekly_average': 5239.4841999999999, u'substrate_flow_phosphate_calculated': 60.630099999999999, u'substrate_flow_phosphate_calculated_monthly_average': 55.562560854524499, u'substrate_flow_phosphate_calculated_moving_average': 60.630099999999999, u'substrate_flow_phosphate_calculated_weekly_average': 60.656231899037302, u'substrate_flow_substrate_volume_flow_measured': 29326.0, u'substrate_flow_substrate_volume_flow_measured_monthly_average': 26769.935483870999, u'substrate_flow_substrate_volume_flow_measured_moving_average': 29326.0, u'substrate_flow_substrate_volume_flow_measured_weekly_average': 29353.0}

Could it be the datetime field?

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by Renskers

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Keywords raw sql iterate added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 4 years ago by Renskers

  • Resolution set to duplicate
  • Status changed from new to closed

This ticket can be closed, see ticket #13710 for fix.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.