SphinxSE with MariaDB not returning result - mariadb

I am using MariaDB 10.1.19 and Sphinx 2.2.10
I am trying to query the Sphinx server using SphinxSE plugin available in MariaDB but I'm getting "OK" as response instead of result (rows).
Query : SELECT * FROM from_sphinx_documents Where query ="eml";
Screenshot of Database Query
I validated Sphinx server by querying it using test jar file and I'm able to get the result there.
Query from command Line
Below is the structure of my Proxy Table :
CREATE TABLE from_sphinx_documents(
id BIGINT UNSIGNED NOT NULL,
weight INTEGER NOT NULL,
query VARCHAR(3072) NOT NULL,
group_id INTEGER,
_sph_count INTEGER,
CASE_ID INTEGER,
FOLDER_ID INTEGER,
DOC_ID INTEGER,
INDEX(query)
) ENGINE=SPHINX CONNECTION ="sphinx://10.0.10.150:9675/documents"
Please can anybody shed a light on it. Is it a version mismatch issue ?

Related

SQLite3 insertion into foreign key table doesn't work

I have an SQLite3 database running on a Python Flask server. I am trying to insert values into foreign key database but the values for the foreign key are set at Null.
In my Flask application.py file:
from flask import Flask
from cs50 import SQL
app = Flask(__name__)
db = SQL("sqlite:///test.db")
db.execute("CREATE TABLE 'people' ('id' integer, 'name' varchar(100), PRIMARY KEY(id))")
db.execute("CREATE TABLE 'friendships' (person_id INTEGER,'id' smallint, 'friends' boolean, FOREIGN KEY(person_id) REFERENCES people(id))")
At some point in the code I want to insert a 'friendship' into the referenced database, assuming I have two people with ids 1 and 2 in the 'people' table. Therefore, I run the code:
db.execute("INSERT INTO friendships (person_id, id, friends) VALUES (1, 2, 1)")
This leaves me with a null value for this inserted row in the person_id field, and have no clue why it has happened. I'm also unable to find anything on similar problems online, so I would really appreciate any help.
Edit:
The code works on itself but I tried to insert an input from a non-existent form input value of person_id from the client-side to the server. This resulted in null values being submitted to the server, consequently ending up in the database.

SQLite CREATE TRIGGER ... SQLite error 1 with statement: incomplete input

trying to create a trigger in Xcode / Swift5 / GRDB. the trigger in the codeblock below fails silently, so I move it and see the error in the title [I have removed the text of the SQL statement from the title]. the weird part is that DB Browser will run the SQL and CREATE the trigger just fine. and the app responds as expected with the externally created trigger. and the UPDATE within seems to work fine outside of the trigger.
opened an issue with the GRDB github repo...just passing the raw SQL thru. check several validators online. all either said there was nothing wrong, or failed on CREATE TABLE in the block below...so no faith in any of the validators.
remembered I have DraftCode on the ipad, with phpLiteAdmin included. send the SQL over and get the same incomplete input error. move back to the desktop...update PHP, and get phpLiteAdmin...same error.
so...it's either a SQLite bug like https://github.com/sqlitebrowser/sqlitebrowser/issues/1470? or more likely a syntax error on my part. I've never played with triggers before...so I may be the dumbass overlooking the obvious. if so, please help me rectify.
one more bit of interesting... in phpLiteAdmin, using the trigger builder, everything works just fine. but trying to run the resulting create SQL statement, copied/delete trigger/and pasted back in, generates the same error
SQLite version: 3.31.1
PHP version: 7.3.14
phpLiteAdmin version: 1.9.8.2
any help with creating the trigger in either GRDB or phpLiteAdmin as a SQL statement would be appreciated. thnx.
CREATE TABLE CartItem (
id INTEGER PRIMARY KEY AUTOINCREMENT,
transactionID INTEGER DEFAULT NULL,
wasReceived BOOLEAN,
sku VARCHAR,
label VARCHAR,
description VARCHAR,
unitLabel VARCHAR,
cost DOUBLE,
wholesale DOUBLE,
retail DOUBLE,
tax DOUBLE,
cartQty FLOAT,
modified REAL
);
-- because 'transaction' is reserved
CREATE TABLE TransXion (
id INTEGER PRIMARY KEY AUTOINCREMENT,
transactionNum VARCHAR,
shippingSubtotal DOUBLE,
taxableSubtotal DOUBLE,
nontaxableSubtotal DOUBLE,
subtotal DOUBLE,
total DOUBLE,
paymentsSubtotal DOUBLE,
balance DOUBLE,
itemsWereRcvd BOOLEAN,
locked BOOLEAN,
modified REAL
);
CREATE TRIGGER insert_TransXion_Dollar_Values_trigger
AFTER INSERT ON CartItem
WHEN transactionID = new.transactionID
BEGIN
UPDATE TransXion
SET total = (
SELECT SUM(ci.retail) AS retail_total
FROM CartItem ci
WHERE ci.transactionID = TransXion.id
)
WHERE id IN (
SELECT transactionID
FROM CartItem ci
WHERE ci.transactionID = TransXion.id
);
END;
In phpLiteAdmin's SQL tab, statements are separated by the delimiter that you can configure below the input tab. By default, this is ;.
In your trigger definition you use ;, but splitting what you enter at this point results in those two queries:
First query:
CREATE TRIGGER insert_TransXion_Dollar_Values_trigger
AFTER INSERT ON CartItem
WHEN transactionID = new.transactionID
BEGIN
UPDATE TransXion
SET total = (
SELECT SUM(ci.retail) AS retail_total
FROM CartItem ci
WHERE ci.transactionID = TransXion.id
)
WHERE id IN (
SELECT transactionID
FROM CartItem ci
WHERE ci.transactionID = TransXion.id
);
second query:
END;
So this obviously fails. You can simply configure another delimiter like $ to make sure it executes as one query.

i'm unsure as to why i'm unable to run this sql script [duplicate]

This question already has answers here:
MySQL error 1064 syntax but everything seems fine
(3 answers)
Closed 3 years ago.
created this with my sql and unsure what is wrong with the script
CREATE TABLE IF NOT EXISTS `restaurant`.`restaurant` (
`_id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`added_date` VARCHAR(30) NULL,
`tele_number` VARCHAR(8) NULL,
`about` TEXT(1024) NULL,
`average_rating` INT NULL,
`price` VARCHAR(10) NULL,
`opening_hour` VARCHAR(255) NULL,
`restaurantcol` VARCHAR(45) NULL,
PRIMARY KEY (`_id`),
UNIQUE INDEX `_id_UNIQUE` (`_id` ASC) VISIBLE,
UNIQUE INDEX `tele number_UNIQUE` (`tele_number` ASC) VISIBLE)
ENGINE = InnoDB
error given:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' UNIQUE INDEX tele number_UNIQUE (tele_number ASC) VISIBLE) ENGINE = InnoD' at line 12
The error messages of MySQL contain the part of the query that has not been parsed because the last parsed token is the one that produces the error. This means the word before " UNIQUE INDEX tele number_UNIQUE ..." is the problem. That word is VISIBLE.
The VISIBLE keyword has been introduced in MySQL 8.0 and you probably use an earlier version.
By default, the indexes are VISIBLE. You can safely drop this keyword from the query. On MySQL 8 you will get the same result as when you use it. On MySQL 5 the concept of invisible indexes does not exist, all indexes are visible.
I see now in the error message that you are not using MySQL but MariaDB. MariaDB is a fork of MySQL 5 that is compatible with MySQL up to some point. You will find many small differences here and there.

SQLite SQL error or missing database (no such table)

Hi everyone I am having some problems with my SQLite database in my java program. I am trying to retrieve data from a couple of tables but it says my table doesn't exist. I have checked using DB Browser and it's definitely there, so I'm not sure what I'm doing wrong. This is the error I receive:
[SQLITE_ERROR] SQL error or missing database (no such table: staff_clocked_in.clock_in_time)
SELECT * FROM staff, staff_clocked_in.clock_in_time WHERE staff.staff_id = staff_clocked_in.staff_id;
I'm sure my tables exist and there is data in both tables, here is a screenshot of my db browser.
If it helps, this is how I have setup my tables:
STAFF:
CREATE TABLE IF NOT EXISTS staff (staff_id INTEGER PRIMARY KEY NOT NULL, first_name TEXT NOT NULL, last_name TEXT NOT NULL, job_title TEXT NOT NULL);
STAFF_CLOCKED_IN:
CREATE TABLE IF NOT EXISTS staff_clocked_in (staff_id INTEGER PRIMARY KEY NOT NULL REFERENCES staff(staff_id), clock_in_time DATETIME NOT NULL);
Can anyone see anything wrong with my query? I'm not good with databases so hopefully it's just something simple.
The error message is correct staff_clocked_in.clock_in_time is not a table.
You should use staff_clocked_in instead which is your table.
So the fixed query should look like
SELECT *
FROM staff, staff_clocked_in
WHERE staff.staff_id = staff_clocked_in.staff_id;

Example Needed of Phonegap Sqlite Insert record and then insert other records into a different table

I have it a point that has really got me stuck and help is need
I have two tables
1) Jobs
2) JobNotes
Jobs is made up like the following
ID integer PRIMARY KEY,
Name nvarchar(100) COLLATE NOCASE
etc..
JobNotes is made up like the following
ID integer PRIMARY KEY,
JobID integer .
Notes nvarchar(100) COLLATE NOCASE
FOREIGN KEY ([JobID ]) REFERENCES Jobs,
When i insert a job into the database I need to insert the jobnote and set the JobID to be the id of the job just inserted previously.
Has anyone got examples or know of a method this can be accomplished using phonegap & sqlite.
Best Regards,
Lmac
After doing the insert I get the max id and then pass this into another function that updates the Foreign key.
Its not the most desired way but so far seems to work.

Resources