Search code examples
mysqlsqlsqliteguidsql-delete

How do I delete a row from Sqlite using ID where my ID is binary data (GUID)


So I have a Sqlite table [Customers] and a column [CustomerId] which is a Guid but as there is no Guid type in sqlite I have saved it as binary so I thought I could use the statement:

delete from [Customers] where [CustomerId] ='|����8B�����\�'

where |����8B�����\� is my binary representation in my Sqlite explorer, but this returns

(0) Rows Affected

How can I delete a row based on my Id column which is effectively a Guid


Solution

  • There are two way of using binary data:

        guid = ...
        sql = "DELETE FROM Customers WHERE CustomerId = ?"
        db.execute(sql, [guid])