Jump to content

SQLite Tables names


Bonsai

Recommended Posts

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

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

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

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

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...