开发者

qt4: how to export a table to sql script?

Can we export schema of 开发者_运维问答a table and it's data from qt code? Or can we do it with sql script, a query that return a table's schema?


You can probably manage to export simple tables in a generic manner using only the functions provided by QSqlDatabase (via the tables() and records functions as a starting point), but as far as I know, you'll need to use database-specific queries to get complete schema information.

This is best done, in my opinion, with your specific database implementation's tools. For instance, SQLite has a .dump command that does just that. MySQL has a dedicated mysqldump utility. PostgreSQL has pg_dump, etc...

It's safer to use pre-built tools for your specific engine. Getting all the DDL statements correct, plugging in the keys and triggers at the right time, worrying about encoding, ... is quite a task.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜