title: SQLITE what are the restricted characters for identifiers
body: <p>I am trying to build a system where SQL parameters gets automatically bound to new queries. According to this thread:</p>
  
  <p><a href="https://stackoverflow.com/questions/751719/sql-server-invalid-characters-in-parameter-names">SQL Server - Invalid characters in parameter names</a></p>
  
  <p>The @, _ and # characters should be allowed inside identifiers. So I tried to build parameters as:</p>
  
  <p>:tablename#fieldname</p>
  
  <p>But when doing do I get error:</p>
  
  <blockquote>
    <p>PBdatabase.select_query: [1] DB[2] prepare() SELECT * FROM creature WHERE pk = :creature#pk [near "#pk": syntax error]</p>
  </blockquote>
  
  <p>It seems it does not like the # character, I tried with the underscore, it seem to work but I am already using the underscore in field names. This is why I wanted to use a different character.</p>
  
  <p>Since the thread above talked about SQL server, the restricted characters could be different in SQLITE. I found the list of SQLITE restricted keywords, but not characters.</p>
  
  <p>Does anybody know which other special character I could use? </p>
  
  <hr>
  
  <p>Update</p>
  
  <p>Somebody want to know what use I have for this. Here is an example, let say you have 2 tables with a 1 to N relationship: Fleet contains ships.</p>
  
  <p>You want to display a form made of 2 blocks, where the top display 1 selected fleet at the time. Where the bottom block list all the ships in the fleet.</p>
  
  <p>The first block query will be something like:</p>
  
  <pre><code>SELECT pk, number, location  FROM fleet;
  </code></pre>
  
  <p>Then the fields of the selected entry will be put in a registry of field with the following names (Assuming the # symbol would be valid):</p>
  
  <pre><code>:fleet#pk
  :fleet#number
  :fleet#location
  </code></pre>
  
  <p>Then the second query for the second block would be ran including the registered fields above. So the query would look like:</p>
  
  <pre><code>SELECT pk, fk_fleet, name  FROM ship WHERE fk_fleet = :fleet#pk
  </code></pre>
  
  <p>This query use a parameter from the query above. The identifier will be replaced by the value from the previous query. This allow to display only the ships linked with the selected fleet above instead of all the ships available.</p>
  
  <p>Now some of you might say that I could simply save the variables I want and pass them in parameter to the next query. The problem is that all the queries are loaded from a database. I actually don't know which query I am going to run and which value I will need to save for another query. Instead I save them all in a registry and if another SQL statement ask for a parameter, the value will be available.</p>