Найти - Пользователи
Полная версия: Файловые БД
Начало » Базы данных » Файловые БД
1 2
well
Всем привет! Появилась следующая задача: взять текстовый документик весом около 1 гига, распарсить и сделать очень быстрый поиск по нему. Решил использовать файловую базу данных, возможности сатвить сервер БД, к сожалению, нет. Полазил в инете и остановился на 2 вариантах: MySQL и Berkeley DB. Вроде, как обе поддерживают “файловый” вариант. Может кто подскажет, какую лучше, если учесть, что ПО будет на Python под Windows? Заранее спасибо.
Ferroman
SQlLite.
clopomor
іще може бути Firebird
якщо багато оперативки то можна попробувати Memcached
чи розміщувати документ на диску в оперативці, або ж відображати в пам"ять
well
clopomor
іще може бути Firebird
якщо багато оперативки то можна попробувати Memcached
чи розміщувати документ на диску в оперативці, або ж відображати в пам"ять
Нажаль, оперативки небагато :(, але дякую за пораду.

Ferroman
SQlLite.
Как-то я проморгал этот вариант, спасибо большое.
slav0nic
если простая структура БД то bsddb будет быстрее
well
slav0nic
если простая структура БД то bsddb будет быстрее
Структура, действительно, простая, спасибо за совет!
well
Покрутил Berkeley DB и SQlLite. Остановился на SQlLite, так как проще в использовании, как мне показалось. Работает довольно-таки шустро, но застопорился на этапе поиска по базе. А именно: в базе хранятся кириллические данные и латиница - все в utf8. Когда делаю так:
...
qery = "select * from mainTable where useName like '%" + name + "%';"
p = c.execute(qery)
...
то регистр игнорируется только, если name задана латиницей. То есть:
если в таблице есть поле useName, равное ВЛАДИМИР, а name = влад, то запрос не найдет это поле;
если в таблице есть поле useName, равное владимир, а name = влад, то запрос найдет это поле;
если в таблице есть поле useName, равное VLADIMIR, а name = vlad, то запрос найдет это поле;
Не подскажете, в чем может быть проблема или лучше создать отдельную ветку?
PooH
отсюда http://www.sqlite.org/faq.html#q18
Case-insensitive matching of Unicode characters does not work.

The default configuration of SQLite only supports case-insensitive comparisons of ASCII characters. The reason for this is that doing full unicode case-insensitive comparisons and case conversions requires tables and logic that would nearly double the size of the SQLite library. The SQLite developers reason that any application that needs full unicode case support probably already has the necessary tables and functions and so SQLite should not take up space to duplicate this ability.

Instead of providing full unicode case support by default, SQLite provides the ability to link against external unicode comparison and conversion routines. The application can overload the built-in NOCASE collating sequence (using sqlite3_create_collation()) and the built-in like(), upper(), and lower() functions (using sqlite3_create_function()). The SQLite source code includes an “ICU” extension that does these overloads. Or, developers can write their own overloads based on their own unicode-aware comparison routines already contained within their project.
well
PooH
отсюда http://www.sqlite.org/faq.html#q18
Case-insensitive matching of Unicode characters does not work.

The default configuration of SQLite only supports case-insensitive comparisons of ASCII characters. The reason for this is that doing full unicode case-insensitive comparisons and case conversions requires tables and logic that would nearly double the size of the SQLite library. The SQLite developers reason that any application that needs full unicode case support probably already has the necessary tables and functions and so SQLite should not take up space to duplicate this ability.

Instead of providing full unicode case support by default, SQLite provides the ability to link against external unicode comparison and conversion routines. The application can overload the built-in NOCASE collating sequence (using sqlite3_create_collation()) and the built-in like(), upper(), and lower() functions (using sqlite3_create_function()). The SQLite source code includes an “ICU” extension that does these overloads. Or, developers can write their own overloads based on their own unicode-aware comparison routines already contained within their project.
Спасибо, как-то не ожидал даже такого хода событий.
Если я правильно понял, то без учета регистра ищется только текс в ASCII. Если нам надо искать в utf8, то юзаем функции upper() и lower(), которые не работают с русским. Но получается следующая странность: в дополнении к Firefox SQLite Manager все прекрасно ищется именно в той БД, в которой я через питон не могу найти. То есть, делаю так:
select * from mainTable where useName like '%ВлАд%'
и он находит поля.
PooH
Посмотрите вот здесь http://docs.python.org/library/sqlite3.html#registering-an-adapter-callable
Connection.create_function(name, num_params, func) вроде должна помочь, попробывал бы сам, но уже страшно спать хочу :)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB