Python Forum
error when dealing with uuid - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: error when dealing with uuid (/thread-33252.html)

Pages: 1 2


error when dealing with uuid - vj78 - Apr-10-2021

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


RE: error when dealing with uuid - ibreeden - Apr-11-2021

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.


RE: error when dealing with uuid - vj78 - Apr-11-2021

(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.


RE: error when dealing with uuid - vj78 - Apr-11-2021

(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.


RE: error when dealing with uuid - ibreeden - Apr-11-2021

(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.


RE: error when dealing with uuid - vj78 - Apr-11-2021

(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.


RE: error when dealing with uuid - vj78 - Apr-11-2021

(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().


RE: error when dealing with uuid - vj78 - Apr-11-2021

Question now is how to use UUID function?


RE: error when dealing with uuid - ibreeden - Apr-11-2021

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?


RE: error when dealing with uuid - vj78 - Apr-11-2021

(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()