I have problem when I trying to insert object to database.
Looks like it's convertion problem. Is there a way to fix this?
I, [2017-10-28T14:02:19.923386 #56398] INFO -- : [49eba256-de7f-48df-8d00-05148a6495d3] Completed 500 Internal Server Error in 286ms (ActiveRecord: 9.5ms)
F, [2017-10-28T14:02:19.925305 #56398] FATAL -- : [49eba256-de7f-48df-8d00-05148a6495d3]
F, [2017-10-28T14:02:19.925557 #56398] FATAL -- : [49eba256-de7f-48df-8d00-05148a6495d3] ActiveRecord::StatementInvalid (Encoding::UndefinedConversionError: U+0142 from UTF-8 to US-ASCII: INSERT INTO "RECIPE_INGREDIENTS" ("QUANTITY", "RECIPE_ID", "INGREDIENT_ID", "CREATED_AT", "UPDATED_AT", "ID") VALUES (:a1, :a2, :a3, :a4, :a5, :a6)):
F, [2017-10-28T14:02:19.925663 #56398] FATAL -- : [49eba256-de7f-48df-8d00-05148a6495d3]
This happens only when I using polish characters like ł, ą, ć
It rather looks as if your underlying database is configured with a US7ASCII characterset which doesn't support UTF8 characters, but your application is a UTF8 application. You'll likely need to work with the DBA team to get a database with AL32UTF8 or similar character set.
Related
I am trying to fetch historics data of the day and to print it.
the error i am getting is :
sqlite3 : Operational error near "(" : syntax error
import sqlite3 as sqlite
import sys
import time
conn = sqlite.connect('places.sqlite.db')
c = conn.cursor()
today = str(time.time())
here i am selecting the 10 first caracter because i want to search for a unix epoch match in seconds and not in milliseconds ( so only the first 10 are interesting to me)
c.execute("SELECT * FROM moz_places WHERE LEFT(last_visit_date, 10)='"+today+"'")
user1 = c.fetchone()
print(user1)
As mentionned earlier, i get "sqlite3 : Operational error near "(" : syntax error"
Do you what is wrong there ?
Here is how to convert moz_places.last_update_time into a string, 'YYYY-MM-DD HH:MM:SS':
UTC: datetime(last_visit_date/1000000, 'unixepoch')
Local time zone: datetime(last_visit_date/1000000, 'unixepoch','localtime')
Here is a link to SQLite doc on Date and Time Functions.
The today string created in python should match format exactly (because it will be doing a string comparison).
From the comments: the name of the places database in Firefox is places.sqlite (not places.sqlite.db). The database name should include full or relative path if it is not in your current working directory.
I have setup an Oracle gateway connected to an Informix IDS database created with an utf8 codeset.
In my dg4imfx file I have HS_LANGUAGE=AMERICAN_AMERICA.WE8MSWIN1252.
With HS_FDS_TRACE_LEVEL=DEBUG it seems that the Oracle client sends the value of e acute in the update statement with a cp850 codeset page:
00: 55504441 54452022 646F7373 6965725F [UPDATE "XXXXXXX_]
10: 616A5F74 65737422 20534554 20226C69 [XX_XXXX" SET "CC]
20: 65755F73 746F636B 61676522 203D2027 [CC_CCCCCCCC" = ']
30: **82**27 [.']
If I run:
echo é|iconv -f utf8 -t cp850|xxd
it gives 0x82.
What advice can you give about the HS_LANGUAGE parameter syntax use?
I have a BPEL Web Service. when I set the output type to XML , it has no problem and the utf-8 characters are working well. but when I set the output type to json, the utf-8 parts of the result goes wrong :
{
name :'ارست',
Code:12544,
Country: 'China',
Adress : 'Sian Street'
}
any suggestion to solve this problem will be appreciated.
This is my code to insert a few lines in my simple "series" table:
db = sequel.postgres(config['dbname'],:user=>config['user'],:password=>config['password'],:host=>config['host'],:port=>config['port'],:max_connections=>10)
#db.create_table? 'series' do
primary_key "series_id" , :autoincrement=>true
String "series_name"
end
seriesDS = db['series']
seriesDS.insert('series_name' => 'test_value')
At seriesDS.insert I get a
Sequel::DatabaseError - PG::SyntaxError: ERREUR: erreur de syntaxe sur ou près de « series »
I didn't manage to get the full SQL query for analysys in STDOUT. It's strange because I added this:
logger = Logger.new STDOUT
logger.level = Logger::DEBUG
db.loggers << logger
It appears to be generating the wrong SQL, but I have no clue to the error's source.
I'm using:
Ruby 2.2.5
Sequel 4.4.1
Postgresql 9.6
The program is launched using ruby -E utf8.
Sequel uses Ruby symbols to represent SQL identifiers. At the very least, you must use seriesDS = db[:series].
Other cases where you want an SQL identifier you should probably switch from using strings to symbols.
Here is my code:
$this->db->select('course_name AS Course Name,course_desc AS Course Description,display_public AS Display Status',FALSE);
$this->db->from('courses');
$this->db->where('tennant_id',$tennant_id);
$this->db->order_by('course_name','ASC');
$query = $this->db->get();
and I got an error:
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Name, course_desc AS Course Description, display_public AS Display Status FROM (' at line 1
and I got an error:
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Name, course_desc AS Course Description, display_public AS Display Status FROM (' at line 1
SELECT course_name AS Course Name,
course_desc AS Course Description,
display_public AS Display Status
FROM (`courses`) WHERE `tennant_id` = 'elicuarto#apploma.com'
ORDER BY `course_name` ASC
Filename: C:\wamp\www\coursebooking\system\database\DB_driver.php
Line Number: 330
Try
$this->db->select('course_name AS `Course Name`, course_desc AS `Course Description`, display_public AS `Display Status`', FALSE);
It's the space in your alias that is messing with you.
UPDATE
I'm not sure why you would want to, but I see nothing preventing you from writing
$this->db->select("course_name AS `{$variable}`", FALSE);
(showing just one field for simplicity)
UPDATE 2
Should be standard string conversion so I don't know why it doesn't work for you.. there's always split strings...
$this->db->select('course_name AS `' . $variable . '`', FALSE);