Python Forum

Full Version: error when dealing with uuid
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I have this sql statement and it gives me error: Unknown column 'guid' in 'NEW' mysql

SQL Statement in python: INSERT INTO user (username, userpassword , admin) VALUES (%s, %s, %s )

Table structure is:
userid
username
userpassword
userguid
admin

userid is auto increment
userguid is uuid() function
You will have to show more of your program. And show the complete error message. The error you mention does not originate from the insert statement you show us.
(Apr-11-2021, 09:42 AM)ibreeden Wrote: [ -> ]You will have to show more of your program. And show the complete error message. The error you mention does not originate from the insert statement you show us.
I am only getting this error message posted. It doesn’t tell me anything else. I tried running this statement inside of MySQL and from python it gives me the same errors.
(Apr-11-2021, 09:42 AM)ibreeden Wrote: [ -> ]You will have to show more of your program. And show the complete error message. The error you mention does not originate from the insert statement you show us.
I am only getting this error message posted. It doesn’t tell me anything else. I tried running this statement inside of MySQL and from python it gives me the same errors.
(Apr-10-2021, 02:07 PM)vj78 Wrote: [ -> ]userguid is uuid() function
Where and how is the uuid() function defined? Please show us the code.
(Apr-11-2021, 11:52 AM)ibreeden Wrote: [ -> ]
(Apr-10-2021, 02:07 PM)vj78 Wrote: [ -> ]userguid is uuid() function
Where and how is the uuid() function defined? Please show us the code.

Ok, I am 1 step further. There was a trigger that got created by default while creating this uuid or guid field. I deleted that trigger now it is inserting rows using the MySQL sql prompt screen.

The UUID function just inserts UUID() as a string inside of the userguid column. So, it’s not working as planned. I will post a print screen of how I created it.
(Apr-11-2021, 02:39 PM)vj78 Wrote: [ -> ]
(Apr-11-2021, 11:52 AM)ibreeden Wrote: [ -> ]Where and how is the uuid() function defined? Please show us the code.

Ok, I am 1 step further. There was a trigger that got created by default while creating this uuid or guid field. I deleted that trigger now it is inserting rows using the MySQL sql prompt screen.

The UUID function just inserts UUID() as a string inside of the userguid column. So, it’s not working as planned. I will post a print screen of how I created it.

[Image: image-22.png.webp]

I am going into the mysql admin panel. I select the database and then the table from left hand navigation. Then click add column.

[Image: Add-New-Column.png]

In here, I am add the name, varchar, length 100, and selecting defined from default column and enter uuid().
Question now is how to use UUID function?
You could of course also implement this function in Python. But the question is: what does the function do? Can you find the text of the trigger?
(Apr-11-2021, 06:14 PM)ibreeden Wrote: [ -> ]You could of course also implement this function in Python. But the question is: what does the function do? Can you find the text of the trigger?
Yes, I think I should implement this function in Python instead.
The function is supposed to generate a GUID which is a unique id.
I deleted the old one that was causes the error. Now, I wish I could recover it to see how it was build.
I am trying to build this new trigger:

INSERT INTO user
SET action = 'insert',
user.userguid = UUID()
Pages: 1 2