我正在尝试使用postgres(pq lib)数据库使用Goose创建此函数.
我的代码如下:
CREATE OR REPLACE FUNCTION add_userlocation(user_id INT, location_id INT) RETURNS VOID AS
$BODY$
BEGIN
LOOP
UPDATE userslocations SET count = count+1 WHERE userid = user_id AND locationid = location_id;
IF found THEN
RETURN;
END IF;
BEGIN
INSERT INTO userslocations(userid,locationid, count) VALUES (user_id, location_id, 1);
RETURN;
EXCEPTION WHEN unique_violation THEN
END;
END LOOP;
END;
$BODY$
LANGUAGE plpgsql;
Run Code Online (Sandbox Code Playgroud)
当我尝试goose up
它时提供错误:
(pq: unterminated dollar-quoted string at or near "$BODY$
BEGIN
LOOP
-- first try to …
Run Code Online (Sandbox Code Playgroud) 我想从以下网站中提取标题和说明:
view-source:http://www.virginaustralia.com/au/en/bookings/flights/make-a-booking/
使用以下代码片段:
<title>Book a Virgin Australia Flight | Virgin Australia
</title>
<meta name="keywords" content="" />
<meta name="description" content="Search for and book Virgin Australia and partner flights to Australian and international destinations." />
Run Code Online (Sandbox Code Playgroud)
我想要标题和元内容.
我使用鹅但是它没有很好地提取.这是我的代码:
website_title = [g.extract(url).title for url in clean_url_data]
Run Code Online (Sandbox Code Playgroud)
和
website_meta_description=[g.extract(urlw).meta_description for urlw in clean_url_data]
Run Code Online (Sandbox Code Playgroud)
结果是空的
我必须编写一个迁移命令来从索引中删除一列。目前让我们说我有table1
索引col1 and col2
我想col1
从索引中删除。我正在查看https://www.postgresql.org/docs/9.4/static/sql-alterindex.html但似乎我实际上不能删除一列?
如果是的话,删除该列会更好吗?VS如何
另外,如果我需要降级,我想做相反的事情。所以只是想知道如何实现这一目标