This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to conver .sql file into SQLite  RSS feed

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm working with SQLite DB. and I saved 2 tables with their related elements in it. Now I have a sql file format, called create.sql and I want to save it and the info which was saved in it, into my SQlite DB. Could anyone help me how can I convert it if needed or save it as a new table of my DB?
 
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is the typical .sql file, then the file is a simple text file which contains the SQL commands to make tables and enter data into the database. If you are lucky, all you have to do is open the file in a Reader, read the lines into character arrays then execute them on the SQLite database. There are, however, things to consider:
1) Where the .sql file came. Is it a trusted source? Should you have to worry about it destroying data? Injecting bad things? Putting bad/inconsistent data in the database?
2) What the target database is. Is the SQL included in the .sql file general or does it have DB engine specific commands?

you should probably open the .sql file and read it to understand what it will do to make sure the above two issues aren't a problem. If they are, then you have a ton more work to do.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!