Re: [sqlalchemy] Re: Problems with inserting data
dont send tuples as bind parameters for scalar attributes. one or more members of your data dictionary are tuples. On Sep 30, 2010, at 6:12 PM, phasma wrote: If add to sqlalchemy/orm/mapper.py at 1699 line this code: if isinstance(value, tuple): value = value[0] Insert works correctly. On Sep 30, 9:31 pm, phasma xpa...@gmail.com wrote: Hi. I've got autoloadable table: --- class ObjectList(object): pass t_object_list = sa.Table('object_list', meta.metadata, autoload=True, autoload_with=engine) orm.mapper(ObjectList, t_object_list) --- - And when I'm trying insert data: --- - ol = ObjectList() ol.type = data['type'], ol.name = data['name'], ol.address = data['address'], ol.gps_lat = data['gps_lat'], ol.gps_lng = data['gps_lng'], ol._class = data['class'], ol.has_parking = data['has_parking'], ol.has_canteen = data['has_canteen'], ol.has_cafe = data['has_cafe'], ol.has_restaurant = data['has_restaurant'], ol.has_fitness = data['has_fitness'], ol.has_beauty_salon = data['has_beauty_salon'], ol.has_tire_shop = data['has_tire_shop'], ol.has_car_washer = data['has_car_washer'], ol.has_bank = data['has_bank'], ol.has_minibank = data['has_minibank'], ol.has_payment_terminal = data['has_payment_terminal'], ol.has_another = data['has_another'] meta.Session.add(ol) meta.Session.commit() I've got error: ProgrammingError: (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 \'), (\'1\',), (\'1\',), (\'1\',), (\'1\',), (\'A\',), (\'0\',), (\'0\',), (\'0\',), (\'0\' at line 1') 'INSERT INTO object_list (type, name, address, gps_lat, gps_lng, _class, has_parking, has_canteen, has_cafe, has_restaurant, has_fitness, has_beauty_salon, has_tire_shop, has_car_washer, has_bank, has_minibank, has_payment_terminal, has_another) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' (('office',), ('1',)) ... and a total of 18 bound parameter sets Where is problems ? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: Problems with inserting data
at: ol.type = data['type'], print type(data['type']) returns str print ol.__dict__ returns: {u'has_tire_shop': (False,), u'gps_lat': ('2',), '_sa_instance_state': sqlalchemy.orm.state.InstanceState object at 0x7fcc6002b0d0, u'name': ('2',), u'has_fitness': (False,), u'has_another': '', u'has_cafe': (False,), u'has_restaurant': (False,), u'has_canteen': (False,), u'has_payment_terminal': (False,), u'has_bank': (False,), u'has_parking': (False,), u'address': ('2',), u'has_minibank': (False,), u'has_car_washer': (False,), u'gps_lng': ('2',), u'type': ('office',), u'_class': ('A',), u'has_beauty_salon': (False,)} On Oct 1, 2:19 am, Michael Bayer mike...@zzzcomputing.com wrote: dont send tuples as bind parameters for scalar attributes. one or more members of your data dictionary are tuples. On Sep 30, 2010, at 6:12 PM, phasma wrote: If add to sqlalchemy/orm/mapper.py at 1699 line this code: if isinstance(value, tuple): value = value[0] Insert works correctly. On Sep 30, 9:31 pm, phasma xpa...@gmail.com wrote: Hi. I've got autoloadable table: --- class ObjectList(object): pass t_object_list = sa.Table('object_list', meta.metadata, autoload=True, autoload_with=engine) orm.mapper(ObjectList, t_object_list) --- - And when I'm trying insert data: --- - ol = ObjectList() ol.type = data['type'], ol.name = data['name'], ol.address = data['address'], ol.gps_lat = data['gps_lat'], ol.gps_lng = data['gps_lng'], ol._class = data['class'], ol.has_parking = data['has_parking'], ol.has_canteen = data['has_canteen'], ol.has_cafe = data['has_cafe'], ol.has_restaurant = data['has_restaurant'], ol.has_fitness = data['has_fitness'], ol.has_beauty_salon = data['has_beauty_salon'], ol.has_tire_shop = data['has_tire_shop'], ol.has_car_washer = data['has_car_washer'], ol.has_bank = data['has_bank'], ol.has_minibank = data['has_minibank'], ol.has_payment_terminal = data['has_payment_terminal'], ol.has_another = data['has_another'] meta.Session.add(ol) meta.Session.commit() I've got error: ProgrammingError: (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 \'), (\'1\',), (\'1\',), (\'1\',), (\'1\',), (\'A\',), (\'0\',), (\'0\',), (\'0\',), (\'0\' at line 1') 'INSERT INTO object_list (type, name, address, gps_lat, gps_lng, _class, has_parking, has_canteen, has_cafe, has_restaurant, has_fitness, has_beauty_salon, has_tire_shop, has_car_washer, has_bank, has_minibank, has_payment_terminal, has_another) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' (('office',), ('1',)) ... and a total of 18 bound parameter sets Where is problems ? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: Problems with inserting data
I feel I need to sleep. Thank you :) On Oct 1, 2:47 am, Michael Bayer mike...@zzzcomputing.com wrote: you're doing this: data = {} data['type'] = 'some type' class Foo(object): pass ol = Foo() ol.type = data['type'], print ol.type its a tuple, lose the ',' On Sep 30, 2010, at 6:42 PM, phasma wrote: at: ol.type = data['type'], print type(data['type']) returns str print ol.__dict__ returns: {u'has_tire_shop': (False,), u'gps_lat': ('2',), '_sa_instance_state': sqlalchemy.orm.state.InstanceState object at 0x7fcc6002b0d0, u'name': ('2',), u'has_fitness': (False,), u'has_another': '', u'has_cafe': (False,), u'has_restaurant': (False,), u'has_canteen': (False,), u'has_payment_terminal': (False,), u'has_bank': (False,), u'has_parking': (False,), u'address': ('2',), u'has_minibank': (False,), u'has_car_washer': (False,), u'gps_lng': ('2',), u'type': ('office',), u'_class': ('A',), u'has_beauty_salon': (False,)} On Oct 1, 2:19 am, Michael Bayer mike...@zzzcomputing.com wrote: dont send tuples as bind parameters for scalar attributes. one or more members of your data dictionary are tuples. On Sep 30, 2010, at 6:12 PM, phasma wrote: If add to sqlalchemy/orm/mapper.py at 1699 line this code: if isinstance(value, tuple): value = value[0] Insert works correctly. On Sep 30, 9:31 pm, phasma xpa...@gmail.com wrote: Hi. I've got autoloadable table: --- class ObjectList(object): pass t_object_list = sa.Table('object_list', meta.metadata, autoload=True, autoload_with=engine) orm.mapper(ObjectList, t_object_list) --- - And when I'm trying insert data: --- - ol = ObjectList() ol.type = data['type'], ol.name = data['name'], ol.address = data['address'], ol.gps_lat = data['gps_lat'], ol.gps_lng = data['gps_lng'], ol._class = data['class'], ol.has_parking = data['has_parking'], ol.has_canteen = data['has_canteen'], ol.has_cafe = data['has_cafe'], ol.has_restaurant = data['has_restaurant'], ol.has_fitness = data['has_fitness'], ol.has_beauty_salon = data['has_beauty_salon'], ol.has_tire_shop = data['has_tire_shop'], ol.has_car_washer = data['has_car_washer'], ol.has_bank = data['has_bank'], ol.has_minibank = data['has_minibank'], ol.has_payment_terminal = data['has_payment_terminal'], ol.has_another = data['has_another'] meta.Session.add(ol) meta.Session.commit() I've got error: ProgrammingError: (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 \'), (\'1\',), (\'1\',), (\'1\',), (\'1\',), (\'A\',), (\'0\',), (\'0\',), (\'0\',), (\'0\' at line 1') 'INSERT INTO object_list (type, name, address, gps_lat, gps_lng, _class, has_parking, has_canteen, has_cafe, has_restaurant, has_fitness, has_beauty_salon, has_tire_shop, has_car_washer, has_bank, has_minibank, has_payment_terminal, has_another) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' (('office',), ('1',)) ... and a total of 18 bound parameter sets Where is problems ? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.