Jump to content

SQLite Tables names


Bonsai

Recommended Posts

Posted

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

Posted
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!

Posted

I suggest you to use queries like this:

executeSQLQuery("INSERT INTO players(name,color,sound) VALUES(?,?,?)", playerName, colorName, soundName ) 

Posted

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 :(

Posted

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 ) 
  

Posted

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 ) 

Posted

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.

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...