General error 1 unrecognized token

Trying to get data from a legacy database that uses some special characters in a few of the column names. When trying to use the Expression Builder I get the following error "SQLite general error. Code , Message . This occurs even when trying to select it directly in the ...

jjames

kyle_ch

‎2021-07-09

08:47 AM

Author

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

That talks about Global Transformations and to say «Transformations cannot be performed on columns that contain special characters in their name» is a bit of a mislead as I am able to do basic transformations and rename the column (mostly to take out the special character), I am just unable to do anything in the Expression Builder.

Unfortunately, we are looking for a full load followed by CDC.

Tianna

‎2021-07-14

01:59 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

@kyle_ch wrote:

Trying to get data from a legacy database that uses some special characters in a few of the column names. When trying to use the Expression Builder I get the following error «SQLite general error. Code <1>, Message <unrecognized token: «#»>.

This occurs even when trying to select it directly in the MyBalanceNow Columns section of the Expression Builder. example: ACCT#

Thanks in advance for any help.


This function splits up the <character_expression> string into a set of tokens separated by the delimiters specified in the <delimiter_string> and then returns the Nth token where N is the number of occurrence of the token specified by the <occurrence> parameter. See Examples section for sample usages of this function.

Михалыч

687 / 293 / 54

Регистрация: 28.02.2013

Сообщений: 838

1

01.08.2020, 15:17. Показов 11296. Ответов 4

Метки нет (Все метки)


Добрый день! У меня есть база данных:

Python
1
2
3
            cursorObj.execute("""CREATE TABLE objects(id INTEGER PRIMARY KEY, data TEXT NOT NULL,
                                                                 photo BLOB NOT NULL, name_photo TEXT NOT NULL,
                                                                 scale_photo TEXT NOT NULL)""")

Я хочу в data записать значения словаря приведенного к str:

Python
1
2
3
                sql = 'UPDATE objects SET data = "' + str(self.data_obj) + '" where id = ' + str(row[0])
                cursorObj.execute(sql)
                sqliteConnection.commit()

И вот когда мой словарь self.data_obj содержит обычный словарь «ключ-значение» то все нормально, а вот когда в значениях появляются вложенные словари он выдает ошибку

sqlite3.OperationalError: unrecognized token: «{«



0



0x10

3254 / 2056 / 351

Регистрация: 24.11.2012

Сообщений: 4,909

01.08.2020, 16:02

2

Лучший ответ Сообщение было отмечено Михалыч как решение

Решение

Нельзя же собирать запрос конкатенацией строк.

Usually your SQL operations will need to use values from Python variables. You shouldn’t assemble your query using Python’s string operations because doing so is insecure; it makes your program vulnerable to an SQL injection attack (see https://xkcd.com/327/ for humorous example of what can go wrong).

Instead, use the DB-API’s parameter substitution.
[…]

Python
1
2
3
4
5
6
7
8
9
# Never do this -- insecure!
symbol = 'RHAT'
c.execute("SELECT * FROM stocks WHERE symbol = '%s'" % symbol)
 
# Do this instead
t = ('RHAT',)
c.execute('SELECT * FROM stocks WHERE symbol=?', t)
print(c.fetchone())
[...]

https://docs.python.org/3/library/sqlite3.html



1



Михалыч

687 / 293 / 54

Регистрация: 28.02.2013

Сообщений: 838

02.08.2020, 09:29

 [ТС]

3

Цитата
Сообщение от 0x10
Посмотреть сообщение

Нельзя же собирать запрос конкатенацией строк.

До этого работало) Я же правильно понимаю, что если 2 переменные то должно быть 2 знака вопроса (под рукой пока той программы нет, а то бы давно попробовал, а любопытство распирает), т.е. примерно так:

Python
1
2
3
data = str(self.data_obj) 
tmp_id = str(row[0])
cursorObj.execute('UPDATE objects SET data = ? where id = ?', data, tmp_id)



0



3254 / 2056 / 351

Регистрация: 24.11.2012

Сообщений: 4,909

02.08.2020, 09:32

4

Цитата
Сообщение от Михалыч
Посмотреть сообщение

Я же правильно понимаю, что если 2 переменные то должно быть 2 знака вопроса

Да, только execute принимает два аргумента: строку и кортеж.



1



687 / 293 / 54

Регистрация: 28.02.2013

Сообщений: 838

02.08.2020, 09:38

 [ТС]

5

0x10, Спасибо



0



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

02.08.2020, 09:38

Помогаю со студенческими работами здесь

Ошибка при разборе запроса. [ Token line number = 1,Token line offset = 26,Token in error = Наименование ]
Доброго времени суток, никак не пойму в чем проблема.
using System;
using…

Как правильно записать данные в Json
Доброго времени суток, возникла такая проблема.

Имеется массив объектов типа:

dataDocument…

Как правильно записать данные в List?
Пишу программу для создания тестов.
Первый класс

class Answer
{
public String…

Как правильно записать данные в файл PHP
Доброе утро. При попытке записать данные в файл, у меня в файл записывается сначала имя, а потом…

Как правильно записать данные из StringBuilder в combobox?
comboBox2.Items.Add(sb);
Если писать так то все что есть в StringBuilder sb будет записано в одну…

Как правильно записать данные в массив файла
Добрый вечер!
Пишу программу работы с файлами(то есть создать, открыть, сохранить, заполнить,…

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:

5

Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

Содержание

  1. unrecognized token error #1270
  2. Comments
  3. isrep commented Dec 15, 2017
  4. Details for the issue
  5. Useful extra information
  6. I’m opening this issue because:
  7. I’m using DB4S on:
  8. I’m using DB4S version:
  9. I have also:
  10. justinclift commented Dec 15, 2017
  11. isrep commented Dec 16, 2017
  12. justinclift commented Dec 16, 2017 •
  13. isrep commented Dec 16, 2017
  14. justinclift commented Dec 16, 2017
  15. sqlite 3 OperationalError: unrecognized token #4757
  16. Comments
  17. ichorid commented Aug 16, 2019
  18. ichorid commented Aug 16, 2019
  19. qstokkink commented Aug 17, 2019 •
  20. grimadas commented Aug 20, 2019
  21. ichorid commented Sep 14, 2019
  22. ichorid commented Sep 14, 2019
  23. devos50 commented Sep 14, 2019 •

unrecognized token error #1270

Details for the issue

Selecting values in double quotes containing double hyphen substring returns «unrecognized token» error.

Please see example below.
—Error unrecognized token:
select «anything—something»

—no error
select ‘anything—something’

I’m opening this issue because:

  • DB4S is crashing
  • DB4S has a bug
  • DB4S needs a feature
  • DB4S has another problem

I’m using DB4S on:

  • Windows: ( version: ___ )
  • Linux: ( _distro:Ubuntu )
  • Mac OS: ( version: ___ )
  • Other: ___

I’m using DB4S version:

I have also:

  • Tried out the latest nightly version: https://github.com/sqlitebrowser/sqlitebrowser#nightly-builds
  • Searched for an existing similar issue: https://github.com/sqlitebrowser/sqlitebrowser/issues?utf8=%E2%9C%93&q=is%3Aissue%20

The text was updated successfully, but these errors were encountered:

Ouch, that definitely sounds like a bug. Have you tried any of the commits prior to that, to see if that’s the one which introduces it?

The same error with version 3.10.99 from 2017-12-09, I see on my system. Thank you for looking into it.

Oops. Just realised something that should have been obvious to me right away before.

This is probably not a bug after all. With SQL, the single and double quote characters aren’t the same thing.

  • Single quote characters ‘ are used to start and end strings. eg:
  • Double quote characters » are used to start and end identifiers (such as field names). eg:

In the above example, the table bar contains a field called my field with spaces in its name .

Further reference info, in case it’s useful:

With your double quote example, the «unrecognized token» message is probably meaning that it’s looking for a field called (literally) «anything—something», and not finding it. 😉

Thank you for pointing to SQLite documentation.
I have bumped into this while operating with strings already containing single quotes.
It seems that official sqlite3 command line tool does not produce «unrecognized token» error.
Thanks anyway.

Hmmm, yeah you’re right. I’ve just tried it here with the sqlite3 client (and older version, 3.7.17 on my CentOS 7 desktop), and a recent build of DB4S.

It looks like DB4S is getting misunderstanding the double quotes. For example, with this (from above):

In the sqlite3 CLI it works, adding a new row into the table bar . DB4S gives this error instead:

Looking at that error message, there’s an extra » at the start of the TEXT2 string. Guessing here, but this looks like we’re somehow getting the quotes wrong after all.

So. yep this does seem like a bug. Our Execute SQL tab should accept anything that the SQLite CLI does. Thanks for being persistent. 😀

Источник

sqlite 3 OperationalError: unrecognized token #4757

v7.3-RC2.
Happens every 2nd attempt to run Tribler both on Windows and on Linux at the end of the GUI bootup.

The text was updated successfully, but these errors were encountered:

@qstokkink , please look at this.

This happens when you feed a bad query to the database (see https://stackoverflow.com/a/11160750). Though the stacktrace is very limited, it seems to be crashing on the bootstrap file script:

Lines 541 to 548 in 54a2d62

if self . bootstrap and not self . bootstrap . bootstrap_finished and hexlify (
infohash ) == self . session . config . get_bootstrap_infohash () and self . trustchain_community :
self . bootstrap . bootstrap_finished = True
with open ( self . bootstrap . bootstrap_file , ‘r’ ) as f :
sql_dumb = text_type ( f . read ())
self . _logger . info ( «Executing script for trustchain bootstrap» )
self . trustchain_community . persistence . executescript ( sql_dumb )
self . trustchain_community . persistence . commit ()

As I can’t reproduce this, I’ll unassign myself. Passing this to the original author @grimadas.

I couldn’t reproduce it. Let me know if you see it again

It is still there. An it is the most frequent error in the reporter. It has three different forms:
17 traces:

If our reporter does not lie, and this thing still happens, it accounts for at least 20% of all reported traces. It should be assessed immediately with a hotfix release.

Out of the 124 stack traces reported for 7.3.0, 25 are related to this unrecognized token error, so thanks for pointing this out! They are both reported by Windows (32 and 64 bit) and Linux users. This error seems to happen in the sesscb_states_callback method, which is AFAIK, the only method in Tribler that is still invoked on the threadpool. This is also visible in the stack traces.

This method should, like most other methods, be scheduled on the reactor thread and this change is trivial to implement (I will try to do so tomorrow). I’m not sure why we haven’t done this yet, probably because it was not raising any problem up to this point.

Preparing a hotfix release at this point might be a bit hard, since we upgraded the OS of our (builder) Mac machine. There are some pending issues with PyInstaller (addressed in #4837).

Источник

Понравилась статья? Поделить с друзьями:

Читайте также:

  • General bluetooth adapter ошибка 43
  • Generac error 1902
  • Gendex expert dc error 1
  • Gemlux gl ic35pb ошибка e2
  • Gem sqlite3 install error

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии