• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to conver .sql file into SQLite

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic