SQLAlchemy error when adding parameter to string SQL query
<p>I'm trying to compose a string SQL query using SQLALchemy 1.1.2. I followed the explanation from the docs about <a href="http://docs.sqlalchemy.org/en/latest/core/tutorial.html#using-textual-sql" rel="noreferrer">using textual SQL</a> but encountered a syntax error when I ran the following code:</p>

<pre><code>from sqlalchemy.sql import text

# Create a database connection called "connection"...

q = text('USE :name')
connection.execute(q, name='DATABASE_NAME')
</code></pre>

<p>Here's the error message:</p>

<pre><code>"You have an error in your SQL syntax; check the manual that 
corresponds to your MySQL server version for the right syntax to use 
near ''DATABASE_NAME'' at line 1") [SQL: u'USE %s;'] [parameters: 
(u'DATABASE_NAME',)]
</code></pre>

<p>Since I'm using the named colon format and passing the parameters as arguments to <code>connection.execute</code> I can't figure out why this problem is arising. I'm using a MySQL server, but if I read the docs correctly the <code>text</code> method should be DB-agnostic.</p>

<p>Thanks in advance for the help.</p>