Bonsai Posted January 24, 2014 Share Posted January 24, 2014 Hey, I was just trying to create map name tables to save some map data. But it doesn't work. The map names contain a lot of different symbols. So I'm using double quotes around the tables name, but it still doesn't work. Example: mapname: race-portdog executeSQLQuery('CREATE TABLE IF NOT EXISTS " 'mapname' " ... It's shown in the SQL Browser, but that + Symbol is missing and I can't insert any data. I tried some random tables names like "bbbb" and it works fine. Do I have to filter the names first? Bonsai Link to comment
Castillo Posted January 24, 2014 Share Posted January 24, 2014 Show us how are you inserting the data. Link to comment
Bonsai Posted January 24, 2014 Author Share Posted January 24, 2014 Show us how are you inserting the data. executeSQLQuery('INSERT INTO " '..map..' " ... That's working fine as long as I take only letters as table name. I also tried "bb-bb" and it didn't work again. So the problem is this "-", but shouldn't it still work with quotes? EDIT: I think I got it! Brackets! "[bb-bb]" worked! Thanks! Link to comment
Castillo Posted January 24, 2014 Share Posted January 24, 2014 I suggest you to use queries like this: executeSQLQuery("INSERT INTO players(name,color,sound) VALUES(?,?,?)", playerName, colorName, soundName ) Link to comment
Bonsai Posted January 24, 2014 Author Share Posted January 24, 2014 Yeah, thats what I do. Just the table name depends on the current map name. And it turned out, that brackets do not work with map name... again Link to comment
Castillo Posted January 24, 2014 Share Posted January 24, 2014 Post the whole query, not just a part of it. Link to comment
Bonsai Posted January 24, 2014 Author Share Posted January 24, 2014 Not working: executeSQLQuery("CREATE TABLE IF NOT EXISTS '["..mapname.."]' (playerName TEXT, playerSerial TEXT, timeMS REAL, timeText TEXT, dataRecorded TEXT, extra TEXT)") executeSQLQuery("INSERT INTO '["..map.."]' (playerName, playerSerial, timeMS, timeText, dataRecorded, extra) VALUES(?,?,?,?,?,?)", playerName, playerSerial, timeMS, timeText, dataRecorded, extra ) Working: executeSQLQuery("CREATE TABLE IF NOT EXISTS 'abc' (playerName TEXT, playerSerial TEXT, timeMS REAL, timeText TEXT, dataRecorded TEXT, extra TEXT)") executeSQLQuery("INSERT INTO 'abc' (playerName, playerSerial, timeMS, timeText, dataRecorded, extra) VALUES(?,?,?,?,?,?)", playerName, playerSerial, timeMS, timeText, dataRecorded, extra ) Link to comment
Castillo Posted January 24, 2014 Share Posted January 24, 2014 Creation: executeSQLQuery ( "CREATE TABLE IF NOT EXISTS `?` ( playerName TEXT, playerSerial TEXT, timeMS REAL, timeText TEXT, dataRecorded TEXT, extra TEXT )", mapname ) Inserting: executeSQLQuery ( "INSERT INTO `?` ( `playerName`, `playerSerial`, `timeMS`, `timeText`, `dataRecorded`, `extra` ) VALUES ( ?, ?, ?, ?, ?, ? )", map, playerName, playerSerial, timeMS, timeText, dataRecorded, extra ) Link to comment
Bonsai Posted January 24, 2014 Author Share Posted January 24, 2014 Hmm, its not working. Same error. I'm using mapname = string.gsub(mapname, "-", "") now. That gets it done. Should have sticked to mysql Thanks anyway. Link to comment
Castillo Posted January 24, 2014 Share Posted January 24, 2014 Try copying my code again. Link to comment
Bonsai Posted January 24, 2014 Author Share Posted January 24, 2014 Try copying my code again. Nope, still not working. But its okay, gsub works fine. Link to comment
Spajk Posted January 24, 2014 Share Posted January 24, 2014 It would be better to add a field named "map" to the players table. executeSQLQuery("CREATE TABLE IF NOT EXISTS 'players' (playerName TEXT, playerSerial TEXT, timeMS REAL, timeText TEXT, dataRecorded TEXT, extra TEXT, map TEXT)") executeSQLQuery("INSERT INTO 'players' (playerName, playerSerial, timeMS, timeText, dataRecorded, extra, map) VALUES(?,?,?,?,?,?,?)", playerName, playerSerial, timeMS, timeText, dataRecorded, extra, map) Having tables for each map would be a bit bad. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now