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?
Can we export schema of a table and it’s data from qt code? Or
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can probably manage to export simple tables in a generic manner using only the functions provided by
QSqlDatabase(via thetables()andrecordsfunctions 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
.dumpcommand that does just that. MySQL has a dedicatedmysqldumputility. PostgreSQL haspg_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.