Pycharm database: trigger won't show up when I add it? - python

When I add a trigger using a SQL command run in Python, it executes, but the trigger won't show up in he Database pane of Pycharm? I've got my column folder, my key folder, my foreign keys, and my indices, but where are my triggers? I've already clicked 'Synchronize' and so on.
What's more, when I try to insert into my table, it complains the trigger is invalid! So these two things may be related? And why does it say the trigger is invalid, yet it doesn't show the trigger in the pane above? What can I do to fix it. The trigger is properly specified!

Related

How to fix, PostgreSQL BEFORE UPDATE Trigger on selected columns executed from Django side on the columns not associated with the Trigger?

Basically, I am creating a Django app with a PostgreSQL database, now for a given table on a database I have to use Triggers for preventing update on selected columns, Trigger is working properly from the database side doing what it is made to do, preventing update on selected columns and allowing to update non-associated column with trigger.
Now from the Django side, whenever I try to update the table's fields/columns which are not associated with the trigger, it invokes/executes the trigger preventing the update operation for those not associated fields/columns and this trigger is even being executed when trying to add new record or data from Django side preventing insertion of new record.
Can anyone please help?
Thank you
I found the solution to my problem.
I created a PostgreSQL trigger to prevent the updating of a few columns. From the database side, I tested it and is working completely fine. The problem was with the Django side.
In the database, a single column can be updated by entering a value, it has no connection with other columns so no error in updating the specific column.
For example, a row has two fields, one modifiable and other is prevented with a trigger, so when I modify that modifiable field it will be modified.
The problem with Django, in Django, it will always write the whole object. Like, if you have an object with two fields, one modifiable, the other not, but both are mapped in Django, when you save that object, Django will update both fields, even if only one or none of them have changed.
As the Django update all the fields even if only one field was being changed, the trigger was being invoked.
so I had to look for an option that will allow only to update specified fields or changed/modified fields only and not the other unchanged fields.
I found this update_fields,
update_fields helps me specific which fields should be updated instead of updating the whole row or all the fields.

Is it possible to initiate new entries in Active Directory, or update existing entries in Active Directory, from SQL Server?

I want some user fields to be updated in Active Directory from SQL server. Is it possible to do that or Is it possible to update the fields using python? Any pointers would be greatly helpful!
You can use something like Python LDAP to make changes in Active Directory via the LDAP interface. The challenge is knowing what/when data changes in your database table.
In MySQL, you can use triggers to perform actions when INSERT, UPDATE, or DELETE operations are committed. A trigger could be used to populate a second table that is essentially a changelog. Either remove items from the changelog table when processed and updated into AD or maintain a "last change processed" number within your code and retain the changelog data as an audit log.

Updating mysql database with pyqt and qtablewidget

I have a program that stores my database data in a QtableWidget.
I would like to add EventListener so whenever user edits any column in a row,
It will update immediately the data in the server.
I am trying to think of a way doing this.
The idea is to send an UPDATE query to servers database. But i stuck on finding a way of making it to see the change and update immediately.
Or updating when button clicked after many rows been edited. But then it have to store all the changes so I think the first option is better.
Any advise will be great!
Thanks ahead!
I agree with you; I think the first option is the better one. Here is a way you could achieve that: you could wait for the user to make the change (the table by default should be editable) and when the user presses enter, process the event. To do that, take a look at BeetDemGuise's answer.
After the enter key has been pressed, a signal will be emitted, and you can connect it to a slot function that will look at the current cell data and update it in the database. e.g. signal.connect(handle_signal). In your handle_signal(), you can get the current text (mytable.currentItem().text()), then make the change in the database. If you're using SqlAlchemy it will look something like:
table = self.values.update()
self.engine.execute(table.values(value="[the current text]".
where(table.id == id))
Of course, this will vary depending on what ORM you're using.

Django: object Id exists but the object has been deleted from media files

I am a newbie with Django trying a simple code to upload and delete a file. Following the instructions given at the accepted answer of Need a minimal Django file upload example, I was able to create a successful version to upload a file. However, while trying to delete individual files, I did some blunder, and later fixed it.
The problem is that the files I deleted while testing the first version of deletion code no longer exist as document files, but their IDs still exist somewhere in the memory (I can't figure out where). Although I managed to fix the code, I still get 'Delete' buttons next to the already deleted files (without names), and I can get document IDs when the user presses these buttons.
I have tried restarting the server and deleting the 'Media' folder from storage, but these buttons still exist. I still can't figure out where these reference IDs are stored. I just want a fresh version of the page to be launched without the buttons corresponding to already deleted files.
Any help would be really appreciated.
Thanks in advance.
They are stored in the database. You can access the database with python manage.py dbshell. If you haven't configured anything custom here it's probably SQLite. Here you can look up the correct table by entering .tables. Then you can use SQL to lookup and delete the model records which contain the non existing file references: SELECT * FROM my_table;, DELETE FROM my_table WHERE id = my_id;.

setting custom viewerProcess fails

I am trying to set my viewerProcess option to be 'Show Primary Grade' instead of 'Film' whenever my nuke is booted
However, due to the limiting information I am able to find on the net, I tried inserting the following code nuke.knobDefault("viewerProcess", "Show Primary Grade") in the init.py but I am unable to get it covered, much less not knowing if the code I have written is right or wrong.
As the Show Primary Grade is a custom plugin that my workplace is using (it is shown in this naming in the list of selection), is there any ways to check and make sure that I am writing it right?
Oh and by the way, am I able to set its script Editor to be like Maya, where whenever the user clicks on something, it will display the results in the output field?
The correct command for setting a default Viewer Process is:
nuke.knobDefault('Viewer.viewerProcess', 'Show Primary Grade')
If that's not working, be sure the name you pass is exactly as registered. To check the registered names, run this command:
nuke.ViewerProcess.registeredNames()
Which by default returns:
['None', 'sRGB', 'rec709']
Turns out that I have to write out inside the menu.py file instead of init.py file.
And for some reasons, the naming convention - 'Show Primary Grade' works despite me unable to find the pass name for it even though I am able to track down its gizmo file...

Categories

Resources