Skip to content

Helper Methods

Rob Parham edited this page Dec 28, 2017 · 2 revisions

jSQL has a few helper methods that may also be helpful to you, so it exposes them on the jSQL object.


jSQL.reset()

Delete all tables and then commit the changes to the persistence manager.

Example
jSQL.reset();

jSQL.minify(sql)

Remove SQL comments, extra spaces, tabs, linebreaks from a jSQL string.

Example
var sql = jSQL.minify('-- A Create Query Template \
CREATE TABLE IF NOT EXISTS `myTable` \
(	`String` VARCHAR(20), \
	`Number` INT \
)');

// returns: 'CREATE TABLE IF NOT EXISTS `myTable` ( `String` VARCHAR(20), `Number` INT )'

jSQL.export(export_table_definitions, table_names)

Export your jSQL database. Useful for transferring data to a MySQL database.

Parameters
  • export_tables: If true or undefined, output a "CREATE TABLE" statement as well, else only output data
  • table_names: An array of tables to export. If not defined, will export all of them.
Example
var sql_dump = jSQL.export();

jSQL.import()

Import your jSQL database. Basically this is just a helper function that splits several statements delimited by ;\n and runs them one at a time. This will break if the table data contains the ;\n string.

Example
var sql_dump = jSQL.import(sql_dump);

Clone this wiki locally
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy