question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to print raw sql for Blog.select().where(Blog.id == 1)

See original GitHub issue
q = Blog.select().where(Blog.id == 1)
print(q.sql())

I want to compile to raw sql .

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
coleifercommented, Jul 6, 2020

peewee 2.9.0

That’s a very old version, from March 2017. For peewee 3.0, I think you would actually set quote = ('', '') instead of empty string, but since you’re on such an old version I’m not sure what to advise.

1reaction
coleifercommented, Jul 6, 2020

On your database class, just set the quote attribute to be an empty string.


class HiveDatabase(...)
    quote = ''

Does that address the issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Raw SQL Queries - EF6 - Microsoft Learn
Raw SQL Queries in Entity Framework 6. ... (var context = new BloggingContext()) { var blogId = 1; var blogs = context.Blogs.SqlQuery("dbo.
Read more >
How do I get the query builder to output its raw SQL query as a ...
First way: ... Simply you can do following stuff using toSql() method, $query = DB::table('users')->get(); echo $query->toSql();. If it's not working you can...
Read more >
Six Ways to Get Raw SQL Output From Query Builder in Laravel
The easiest way to get the raw SQL output of this query, is by using the toSql() method: use App\User; User::whereHas( 'orders.payments',fn ($q) ......
Read more >
How to get the raw SQL query from the Laravel Query Builder
The first method to get the query of an Eloquent call is by using the toSql() method. This method returns the query without...
Read more >
How to Execute Raw SQL in SQLAlchemy | Tutorial by Chartio
Here we're inserting two records into our database by using a text() -defined statement. Using the execute Method. The alternative method is to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found