gener=connection.escape(gener)
вы получаете в запросе LIKE "%'blabla'%"
.def escape(self, obj, mapping=None):
"""Escape whatever value is passed.
Non-standard, for internal use; do not use this in your applications.
"""
cursor.execute(script.format(year_from=args.year_from,
year_to=args.year_to,
name="%{}%".format( (args.regexp.translate(str.maketrans({'%': '\%', '_': '\_'})),) ),
gener="%{}%".format( (gener.translate(str.maketrans({'%': '\%', '_': '\_'})),) ),
rating=1,
N=args.N))
SELECT m.title, year, avg(r.rating)
FROM movies AS m
JOIN rating AS r
ON m.movie_id = r.movie_id
WHERE m.year BETWEEN {year_from} and {year_to} AND m.title LIKE {name} AND m.genres LIKE {gener}
GROUP BY r.movie_id, m.title, m.year
HAVING avg(r.rating) > {rating}
ORDER BY avg(r.rating) DESC, m.year DESC, m.title asc
LIMIT {N};
$ctx = stream_context_create(array("ssl" => array("capture_peer_cert" => TRUE)));
$sock = stream_socket_client("ssl://www.google.com:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ctx);
$cert = stream_context_get_params($sock);
$certinfo = openssl_x509_parse($cert['options']['ssl']['peer_certificate']);
// print_r($certinfo);
print "Valid from: " . date_create_from_format("ymdHise", $certinfo["validFrom"])->format("c")
. "\nValid till: " . date_create_from_format("ymdHise", $certinfo["validTo"])->format("c") . "\n";
И ещё ошибка с from psycopg2 import OperationalError, он просто не находит OperationalError
>>> from psycopg2 import OperationalError
>>> OperationalError
<class 'psycopg2.OperationalError'>
>>> psycopg2.__version__
'2.8.6 (dt dec pq3 ext lo64)'
The error 'FATAL: password authentication failed for user "postgres"
Как этот пароль посмотреть или новый создать?
ALTER ROLE postgres WITH PASSWORD '123';
или в psql \password
class vk_api.longpoll.VkLongPoll(vk, wait=25, mode=234, preload_messages=False, group_id=None)
wait — the waiting period (as most proxy servers terminate the connection after 30 seconds, we recommend indicating wait = 25). Maximum: 90.
lp = VkLongPoll(vk_session, group_id=123456789)
postgres=# select '{"email": "a@example.com", "telegram_token": "", "telegram_user_id":""}'::jsonb - 'email';
?column?
------------------------------------------------
{"telegram_token": "", "telegram_user_id": ""}
(1 row)
UPDATE group_settings
SET group_recepients = jsonb_build_object('email', subquery.email, 'telegram_token', '', 'telegram_user_id', '')
FROM (SELECT id, email from users) AS subquery WHERE group_settings.user_id = subquery.id;
IF OLD.bilet_number IN (SELECT bilet_number FROM all_lends)
хотите удалить этого абонента (и только его), то нужно было делать обычный не INSTEAD) триггер и вместо DELETE оператора в конце сделать RETURN OLD
. CREATE USER user_name PASSWORD (SELECT random_string((SELECT random_int_between(5,15))));
Non-optimizable SQL commands (also called utility commands) are not capable of accepting query parameters. So automatic substitution of PL/pgSQL variables does not work in such commands. To include non-constant text in a utility command executed from PL/pgSQL, you must build the utility command as a string and then EXECUTE it, as discussed in Section 43.5.4.
SELECT random_string(SELECT random_int_between(5,15)) INTO pass;
EXECUTE format('CREATE USER %I PASSWORD %L', user_name, pass);
EXECUTE format('GRANT %I TO %I', role_name, user_name);
Changed in version 2.9: the table and fields names are now quoted. If you need to specify a schema-qualified table please use copy_expert().