How to create sqlite database in javascript?

I am starting to work in sqlite. If someone helps me create a sqlite database in javascript , this will be very helpful.

+7
source share
4 answers

Help this script.

<script type="text/javascript"> function createDatabase(){ try{ if(window.openDatabase){       var shortName  =  'db_edentiti';       var version  =  '1.0';       var displayName  =  'Edentiti Information';       var maxSize  =  65536; // in bytes       db   =  openDatabase(shortName, version, displayName, maxSize);           alert('Sqlite Database created');     }   }catch(e){   alert(e);   } } </script> 
+8
source

What do you want to use sqlite for? in firefox you can get sqlite manager with extension so you can create database and tables ... but if you are developing ios you need to create objects in xcode

hope this helps wblade

++, so I suggest you use AJAX instead of Javascript or php

I find:

 <?php $db = new PDO('sqlite:/usr/local/zodiac');$db->beginTransaction(); $q = $db->query("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'zodiac'");if ($q->fetch() === false) { $db->exec(<<<_SQL_ CREATE TABLE zodiac ( id INT UNSIGNED NOT NULL, sign CHAR(11), symbol CHAR(13), planet CHAR(7), element CHAR(5), start_month TINYINT, start_day TINYINT, end_month TINYINT, end_day TINYINT, PRIMARY KEY(id) ) _SQL_ ); $sql=<<<_SQL_ INSERT INTO zodiac VALUES (1,'Aries','Ram','Mars','fire',3,21,4,19); INSERT INTO zodiac VALUES (2,'Taurus','Bull','Venus','earth',4,20,5,20); INSERT INTO zodiac VALUES (3,'Gemini','Twins','Mercury','air',5,21,6,21); _SQL_; foreach (explode("\n",trim($sql)) as $q) { $db->exec(trim($q)); } $db->commit(); } else { $db->rollback(); } ?> 
+2
source

Hi There are several ways to create db using SQLite, since you know that SQLite is very lightweight and very flexible in the data warehouse, the commands are also very easy to remember.

I am a Windows XP user.

On my system, I extracted the SQLite engine 3.X in C: \ Ronald \ Personal \ epmc \ JavaJ2EE

u can any editor like SQLiteBrowser , it is very nice to work with it. no additional milling cutter required.

Open a command prompt and point to the SQLite engine.

In my case, it was C: \ Ronald \ Personal \ epmc \ JavaJ2EE

provide the following command to create the database

  sqlite3.exe TestDB.db; 

As soon as you give this automatically, the database file will be created in a specific place. Then start creating tables like what you did in Oracle or MySQL.

Thanks Ronald Reagan Nathan

+1
source

You can try the SQLite admin:

http://sqliteadmin.orbmu2k.de/

It is a good tool to have anyway.

0
source

All Articles