Help with SQL_PARSE_ERROR When Using Raw SQL Queries in Drizzle ORM with Sqlite ( truso db )

Hello Drizzle ORM Community, https://orm.drizzle.team/docs/goodies#raw-sql-queries-execution I'm currently facing an issue with executing a raw SQL query using Drizzle ORM. I'm trying to count the number of users in the tbl_users table with the following code snippet:
const counts = await db.run(
sql`(SELECT count(*) from ${tbl_users})`.as("count")
);
console.log({ counts });
const counts = await db.run(
sql`(SELECT count(*) from ${tbl_users})`.as("count")
);
console.log({ counts });
However, I'm encountering a SQL parse error that I can't seem to resolve. The error message is as follows:
admin:dev: ❌ tRPC failed on users.getUserList: SQL_PARSE_ERROR: SQL string could not be parsed: near LP, "None": syntax error at (1, 2)
admin:dev: ❌ tRPC failed on users.getUserList: SQL_PARSE_ERROR: SQL string could not be parsed: near LP, "None": syntax error at (1, 2)
admin:dev: ❌ tRPC failed on users.getUserList: SQL_PARSE_ERROR: SQL string could not be parsed: near LP, "None": syntax error at (1, 2)
admin:dev: ❌ tRPC failed on users.getUserList: SQL_PARSE_ERROR: SQL string could not be parsed: near LP, "None": syntax error at (1, 2)
admin:dev: ❌ tRPC failed on users.getUserList: SQL_PARSE_ERROR: SQL string could not be parsed: near LP, "None": syntax error at (1, 2)
admin:dev: ❌ tRPC failed on users.getUserList: SQL_PARSE_ERROR: SQL string could not be parsed: near LP, "None": syntax error at (1, 2)
It seems there's an issue with the way the query is being parsed. I'm wondering if I'm using the sql template literal incorrectly or if there's a different way I should be structuring these types of queries. Could anyone provide some insight into what might be going wrong here, or share how to correctly execute such a query using Drizzle ORM? Any help would be greatly appreciated! Thank you in advance!
Drizzle ORM - Goodies
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server