• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to conver .sql file into SQLite

 
elenora Rezaie
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?
 
Steve Luke
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