Placing widgets via a MySQL or something MySQL abstracted via the global variable
$wpdb that is an instance of the WPDB class is not trivial.
That's not because MySQL is something complicated or because
$wpdb is useless at all but this has do something with the way the widget configuration is stored inside the mysql database options tables.
But there is always a work around. The nature of the widget configuration is stored inside the mysql database options tables. Just read the widgets configuration out of the option (get_option), edit it as you wish (use var_dump to inspect how that array is used) and then store it back into mysql via update_option.
That done you should be able to edit this "via mysql" (e.g. in the database) while making the settings of your wish.
This is quite a quick answer but it probably solves your issue.