Z
Size: a a a
Z
❤
N
pkg_info=# \d+ updates
Table "public.updates"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
----------+-----------------------+-----------+----------+-------------------------------------+----------+--------------+-------------
id | integer | | not null | nextval('updates_id_seq'::regclass) | plain | |
code | character varying(30) | | | | extended | |
unixtime | integer | | | | plain | |
type | character varying(30) | | | | extended | |
pkg_id | integer[] | | | | extended | |
Indexes:
"updates_pkey" PRIMARY KEY, btree (id)
pkg_ids = [17357, 17358, 17359, 17360, 17361, 17362, 17363, 17364, 17365, 17366]
querry_insert = "insert into {} values (default, '{}', '{}', '{}', '{}') returning id;"
id = cursor.execute(querry_insert.format(table, code, unixtime, severity, pkg_ids))
psycopg2.errors.InvalidTextRepresentation: malformed array literal: "[17357, 17358, 17359, 17360, 17361, 17362, 17363, 17364, 17365, 17366]"
LINE 1: ...ues (default, 'CEBA-2014:0714', '1402358400', '', '[17357, 1...
^
DETAIL: Missing "]" after array dimensions.
ВЩ
ВЩ
executemany
, или https://stackoverflow.com/questions/8134602/psycopg2-insert-multiple-rows-with-one-queryВЩ
ВЩ
ВЩ
N
pkg_info=# select * from updates where type='Critical' limit 10 ;
id | code | unixtime | type | pkg_id
------+----------------+------------+----------+---------------------------------------------------------------------------------------
3613 | CESA-2014:0675 | 1402358400 | Critical | {45902,45903,45904,45905,45906,45907,45908}
3622 | CESA-2014:0741 | 1402483741 | Critical | {45974,45975}
3628 | CESA-2014:0889 | 1405507571 | Critical | {46038,46039,46040,46041,46042,46043,46044,46045}
3631 | CESA-2014:0916 | 1406076118 | Critical | {46075,46076,46077,46078,46079,46080,46081,46082,46083,46084,46085,46086,46087,46088}
3632 | CESA-2014:0919 | 1406076847 | Critical | {46089,46090,46091,46092,46093,46094,46095,46096}
3646 | CESA-2014:1144 | 1409785776 | Critical | {46268,46269,46270,46271,46272,46273,46274,46275}
o
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd1 in position 4095: unexpected end of data
if len(MainPluginMg) > 4000:
count = round(len(MainPluginMg) // 4000)
# print(len(MainPluginMg))
last_index = 0
try:
for i in range(count + 1):
n_index = MainPluginMg.rindex('\n', 4000 * i, 4000 * (i + 1))
title = MainPluginMg[last_index:n_index]
print(title)
await ans(title)
last_index = n_index
except Exception as e:
print(e)
title = MainPluginMg[4000 * count:]
await ans(title)
else:
await ans(MainPluginMg, keyboard=keyboard.generate() if keyboard else None)
ПА
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd1 in position 4095: unexpected end of data
if len(MainPluginMg) > 4000:
count = round(len(MainPluginMg) // 4000)
# print(len(MainPluginMg))
last_index = 0
try:
for i in range(count + 1):
n_index = MainPluginMg.rindex('\n', 4000 * i, 4000 * (i + 1))
title = MainPluginMg[last_index:n_index]
print(title)
await ans(title)
last_index = n_index
except Exception as e:
print(e)
title = MainPluginMg[4000 * count:]
await ans(title)
else:
await ans(MainPluginMg, keyboard=keyboard.generate() if keyboard else None)
ПА
ПА
ПА
ПА
VV
ПА
A