Created
April 2, 2013 07:29
-
-
Save tomasikp/5290531 to your computer and use it in GitHub Desktop.
Used to generate charsets for node-mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mysql = require('mysql'); | |
var fs = require('fs'); | |
var connection = mysql.createConnection({ | |
host : 'localhost', | |
user : 'root' | |
}); | |
connection.connect(); | |
connection.query('SELECT collation_name, id FROM information_schema.collations ORDER BY id', function(err, rows, fields) { | |
if (err) throw err; | |
var data = ""; | |
var currentRow = ""; | |
for(var x=0; x<rows.length; x++) | |
{ | |
currentRow = "exports."+rows[x].collation_name.toUpperCase(); | |
while((currentRow.length-30)<0) | |
{ | |
currentRow+=" "; | |
} | |
currentRow+=(" = "+ rows[x].id + ";\n"); | |
data+=currentRow; | |
} | |
fs.writeFile('charsets.js', data,function(err){ | |
}); | |
}); | |
connection.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment