SQL exceptions & fixed SQL script syntax

master
E. Almqvist 3 years ago
parent e397a61096
commit 2efc396773
  1. 12
      src/lib/database.rb
  2. 2
      src/sql/tables/Auction_Category_relation.sql

@ -18,7 +18,7 @@ class EntityModel
begin
q = File.read sql_file # get SQL script
db.query q # run query
self.query q # run query
rescue Errno::ENOENT => err
Console.error "#{err}"
end
@ -43,7 +43,12 @@ class EntityModel
def self.query(q, *args) # query table with query string
Console.debug("Running SQL -> #{q}", *args)
db.execute( q, *args )
begin
db.execute( q, *args )
rescue SQLite3::SQLException => err
Console.error "SQL exception: #{err}", q
end
end
def self.get(attr, filter="", *args) # get data from table
@ -74,8 +79,7 @@ class EntityModel
end
class RelationModel < EntityModel
def self.table1 = nil
def self.table2 = nil
def self.tables = nil
def self.get_relation(id)
roleids = self.get "role_id", "user_id = ?", user_id

@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS "Auction_Category_relation" (
"auction_id" INTEGER NOT NULL,
"category_id" INTEGER NOT NULL,
"category_id" INTEGER NOT NULL
);

Loading…
Cancel
Save