BUG: When creating table, db indexes should be created from DataFrame indexes

Unfortunately my PR #8022 introduced a bug wherein database indexes are not created from DataFrame indexes.  This pull request fixes it, also introduces this feature for the legacy interface, and adds tests to make sure indexes are created as appropriate.
can you add some comments here why it is needed? (+ mention this PR number)
+ mention that the 'hack' can be removed if we drop mysql support (then only sqlite, so we can just use sqlite3's executescript)