Executing SQL statements in Proteus

Hi, I would like to know if there is a way execute SQL statements using python-sql’s table() from models in Proteus. I wrote a script that process some data offline using models and custom sql query. Normally if this were written inside a Trytond module, I would use the cursor from the Transaction instance, i.e.:

cursor = Transaction().connection.cursor()
cursor.execute(product.select(…))

But it seems that Transaction() is not available in Proteus, or I don’t really know how to access it. Can anyone help me with this?

No you can not because proteus is designed to be a client like others.
But you can use trytond-console for server-side scripts.

I see, you are right I forgot, Proteus is really acting like a client.

Regarding the trytond-console approach, is there a way to load a script and have it execute from the command line or console? Something like in Postgresql client psql where you type

\i sql_statements.sql

Nevermind, I was just confused on how trytond-console works, it is actually a trytond capable python console, so I answered my own question. I just use “exec()” just like in a Python console.

You can pipe your script to it like cat myscript.py | trytond-console

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.