Mysql insert with spaces

79 views
Skip to first unread message

Scott Vickery

unread,
Nov 17, 2012, 9:35:33 AM11/17/12
to we...@googlegroups.com
My apologies if this posts twice.  I did not see the original post show up.

I am trying to do an insert into a mysql DB from web.py.  From python, I am using the MySQL library like this:

    import MySQLdb
I have a DB defined like this:

   db = web.database(dbn='mysql', user='root', pw='root', db='todo')

I have the following line

    db.insert('todo', todo_name="test 2")

Everything after the space is truncated.  Any ideas on how to have the entire string inserted?

Thanks,
Scott

Jason Macgowan

unread,
Nov 17, 2012, 10:02:38 AM11/17/12
to we...@googlegroups.com
Just tried it and it works fine for me exactly as it's written.  Can you post entire code?



--
You received this message because you are subscribed to the Google Groups "web.py" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webpy/-/_eiGEEw-QdQJ.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to webpy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webpy?hl=en.

Jason Macgowan

unread,
Nov 17, 2012, 10:03:12 AM11/17/12
to we...@googlegroups.com
What is your database schema?

Scott Gelin

unread,
Nov 17, 2012, 10:03:18 AM11/17/12
to we...@googlegroups.com
DB Schema might not hurt either.


On Sat, Nov 17, 2012 at 10:02 AM, Jason Macgowan <jasonm...@gmail.com> wrote:

Scott Vickery

unread,
Nov 17, 2012, 2:40:15 PM11/17/12
to we...@googlegroups.com
Here is the create for the table in question:

CREATE TABLE `todo` (
  `taskID` int(11) NOT NULL AUTO_INCREMENT,
  `todo_name` varchar(255) NOT NULL,
  `categoryID` int(11) NOT NULL,
  PRIMARY KEY (`taskID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

Thanks,
Scott

Jason Macgowan

unread,
Nov 17, 2012, 2:45:47 PM11/17/12
to we...@googlegroups.com
Still works for me with your schema.


To view this discussion on the web visit https://groups.google.com/d/msg/webpy/-/e9eeiu3jzJsJ.

Scott Gelin

unread,
Nov 17, 2012, 2:46:27 PM11/17/12
to we...@googlegroups.com
Same here.  Next guess would be the way you are selecting/viewing the data stored in your table.

Sent from my iPhone

Scott Vickery

unread,
Nov 17, 2012, 3:05:00 PM11/17/12
to we...@googlegroups.com
Ok.  I'll track it down.  Will post what the issue is for others who may run into it.

Scott

Scott Vickery

unread,
Nov 17, 2012, 3:14:35 PM11/17/12
to we...@googlegroups.com
lol. The problem was in the display, not the persistence:

<input type="text" name="task_name" value='$todo.todo_name></input>
vs
<input type="text" name="task_name" value='$todo.todo_name'></input>

I had no quotes around my value.  I jumped to the conclusion the framework was doing something incorrect.

Sorry for the waste of bandwidth.

Scott

Jason Macgowan

unread,
Nov 17, 2012, 3:29:48 PM11/17/12
to we...@googlegroups.com
It happens :)


To view this discussion on the web visit https://groups.google.com/d/msg/webpy/-/lxelczR6UgIJ.
Reply all
Reply to author
Forward
0 new messages