0

So I have a .db file which basically has 1 table in it with around 100 entries. I want to import this file to a phpmyadmin which only allows me to import SQL files. Note that I only have access using phpmyadmin and I can't connect using navicat,heidisql,... Probably the best option would be to convert the .db to .sql right? I don't really know how all this works so any comment will be useful.

lpares12
  • 3,504
  • 4
  • 24
  • 45
  • Someone asked this before: http://stackoverflow.com/questions/21823164/how-to-convert-db-file-to-sql-file – Evan Fajardo Jun 22 '15 at 18:34
  • @EvanFajardo well, it won't create the inserts, just the create command which I can insert manually, no need of a .sql file for this. But all the entries of the table won't appear in the .sql file, which is basically what I need. – lpares12 Jun 22 '15 at 19:00

2 Answers2

4

So after searching a lot I've found a solution.

  1. Install Firefox.
  2. Add this complement to firefox.
  3. Follow the steps in firefox go to tools -> SQLite Manager -> Database -> Connect Database.
  4. Make sure to select "All Files" and search for your .db file.
  5. Go to Database-> Export Database save with .sql extension.
  6. Open the file.sql with a text editor.
  7. Search for all the " and replace them with '. (Note: use the replace option to make it faster).
  8. Search for all the table names, they will be around ' make sure to delete this '. For example, if you have a query like: DROP TABLE IF EXISTS 'Characters' replace it for: DROP TABLE IF EXISTS Characters, do the same with the INSERTS and all the other queries.
  9. Save the file and you are done.
lpares12
  • 3,504
  • 4
  • 24
  • 45
0

You want to import your database i.e. a .db file into phpmyadmin. That is great. phpmyadmin supports CSV, MediaWiki Table, OpenDocument Spreadsheet, ESRI shape file, XML and SQL.So, obviously you need to convert your .db file into one of the given form. Either you can use a tool for the conversion or there is a simple solution i.e. just right click on the .db file and click on rename. You can name it whatever you want but change the extension from .db to .sql . This must work. And after that you can click on import and attach the changed .db i.e. .sql file into phpmyadmin. I think that would help you. Please let me know either this worked or you tried other thing.

  • basically a .db file and a .sql file are different things, .sql file is made of QUERY sentences while a .db is not, that's why you can't do that. – lpares12 Jun 23 '15 at 12:12