ConDict

Check-in [a9de4f4419]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixed bug for edit-multiusers
Timelines: family | ancestors | descendants | both | testing
Files: files | file ages | folders
SHA1:a9de4f441992e6fbba180f01931fdc7e51960a6e
User & Date: zorro 2012-09-08 21:13:19
Context
2012-09-09
08:14
done delete-function (by ID and pattern check-in: eb602c3be7 user: zorro tags: testing
2012-09-08
21:13
fixed bug for edit-multiusers check-in: a9de4f4419 user: zorro tags: testing
19:43
done edit-function check-in: da8029bf0f user: zorro tags: testing
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to condt.conf.

Changes to condt.py.

294
295
296
297
298
299
300
301

302
303
304


305
306
307
308
309
310
311
...
347
348
349
350
351
352
353

354

355

356
357
358

359
360
361
362
363
364
365
366
367

    def command_add_kinds(self, cur, en, ru):
        """SQL queries for add-command"""
        token = hashlib.md5(bytes(en, 'utf-8')).hexdigest()
        # search token
        sql_list = "SELECT `token` FROM `term` WHERE `token`=(?)"
        cur.execute(sql_list, (token,))
        if cur.fetchone(): raise DublicationDbData()

        # insert in to tables
        sql_list1 = "INSERT INTO `term` (`token`, `en`) VALUES ((?), (?))"
        cur.execute(sql_list1, (token, en))


        sql_list2 = "INSERT INTO `translate` (`term`, `user_id`, `rus`) VALUES (?, ?, ?)"
        cur.execute(sql_list2, (token, self.user_id, ru))
        translate_id = cur.lastrowid
        sql_list3 = "INSERT INTO `progress` (`translate_id`) VALUES (?)"
        cur.execute(sql_list3, (translate_id,))
        return translate_id

................................................................................
            if not result: raise IncorrectDbData()
            # enter en-ru
            en = input('En [' + result[0] + ']:')
            if not en: en = result[0]
            ru = input('Ru [' + result[1] + ']:')
            if not ru: ru = result[1]
            # new token

            token = hashlib.md5(bytes(en, 'utf-8')).hexdigest()

            cur.execute("INSERT INTO `term` (`token`, `en`) VALUES ((?), (?))", (token, en))

            # translate
            cur.execute("UPDATE `translate` SET `rus`=(?), `term`=(?) WHERE `term`=(?) AND `user_id`=(?)", (ru, token, result[2], self.user_id))
            # delete in term if it needed

            cur.execute("SELECT `id` FROM `translate` WHERE `term`=(?)", (result[2],))
            if not cur.fetchone(): cur.execute("DELETE FROM `term` WHERE `token`=(?)", (result[2],))
        except IncorrectDbData as e:
            print('Record not found for current user.')
        except (ValueError, sqlite3.DatabaseError) as er:
            if DEBUG: print(er)
            print("Error, use '.edit ID' (ID is numerical)")
        else:
            self.connect.commit()







|
>
|
|
|
>
>







 







>

>
|
>



>
|
|







294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
...
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374

    def command_add_kinds(self, cur, en, ru):
        """SQL queries for add-command"""
        token = hashlib.md5(bytes(en, 'utf-8')).hexdigest()
        # search token
        sql_list = "SELECT `token` FROM `term` WHERE `token`=(?)"
        cur.execute(sql_list, (token,))
        # if cur.fetchone(): raise DublicationDbData()
        if not cur.fetchone():
            # insert in to tables
            sql_list1 = "INSERT INTO `term` (`token`, `en`) VALUES ((?), (?))"
            cur.execute(sql_list1, (token, en))
        cur.execute("SELECT `id` FROM `translate` WHERE `term`=(?) AND `user_id`=(?)", (token, self.user_id))
        if cur.fetchone(): raise DublicationDbData()
        sql_list2 = "INSERT INTO `translate` (`term`, `user_id`, `rus`) VALUES (?, ?, ?)"
        cur.execute(sql_list2, (token, self.user_id, ru))
        translate_id = cur.lastrowid
        sql_list3 = "INSERT INTO `progress` (`translate_id`) VALUES (?)"
        cur.execute(sql_list3, (translate_id,))
        return translate_id

................................................................................
            if not result: raise IncorrectDbData()
            # enter en-ru
            en = input('En [' + result[0] + ']:')
            if not en: en = result[0]
            ru = input('Ru [' + result[1] + ']:')
            if not ru: ru = result[1]
            # new token
            need_del = False
            token = hashlib.md5(bytes(en, 'utf-8')).hexdigest()
            if token != result[2]:
                cur.execute("INSERT INTO `term` (`token`, `en`) VALUES ((?), (?))", (token, en))
                need_del = True
            # translate
            cur.execute("UPDATE `translate` SET `rus`=(?), `term`=(?) WHERE `term`=(?) AND `user_id`=(?)", (ru, token, result[2], self.user_id))
            # delete in term if it needed
            if need_del:
                cur.execute("SELECT `id` FROM `translate` WHERE `term`=(?) LIMIT 1", (result[2],))
                if not cur.fetchone(): cur.execute("DELETE FROM `term` WHERE `token`=(?)", (result[2],))
        except IncorrectDbData as e:
            print('Record not found for current user.')
        except (ValueError, sqlite3.DatabaseError) as er:
            if DEBUG: print(er)
            print("Error, use '.edit ID' (ID is numerical)")
        else:
            self.connect.commit()

Changes to db.sqlite.

cannot compute difference between binary files

Changes to dict.csv.

1
2


3

4
5
6
7
8

9
10


11
ENGLISH;RUSSIAN
ability;способность


famous;известный

hi;привет
how do you do?;как поживаете?
judo;дзюдо
mistake;ошибка
odd;странно

riding a bike;езда на велосипеде
sailing;парусный спорт


vocabulary;словарь


>
>

>





>


>
>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
ENGLISH;RUSSIAN
ability;способность
can you play the guitar?;вы можете играть на гитаре?
conversation;разговор
famous;известный
guitar;гитара
hi;привет
how do you do?;как поживаете?
judo;дзюдо
mistake;ошибка
odd;странно
restaurant;ресторан
riding a bike;езда на велосипеде
sailing;парусный спорт
sentences;предложения
skill;мастерство
vocabulary;словарь