Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mikes zhang
001
提交
42c65bdb
0
001
项目概览
mikes zhang
/
001
通知
6
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
0
001
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
42c65bdb
编写于
8月 19, 2020
作者:
D
Doug Farrell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Responded to Geir's latest comments and suggestions
上级
28ae3774
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
7 addition
and
8 deletion
+7
-8
python-sqlite-sqlalchemy/project/data/author_book_publisher.csv
...-sqlite-sqlalchemy/project/data/author_book_publisher.csv
+1
-1
python-sqlite-sqlalchemy/project/data/author_book_publisher.db
...n-sqlite-sqlalchemy/project/data/author_book_publisher.db
+0
-0
python-sqlite-sqlalchemy/project/examples/example_1/main.py
python-sqlite-sqlalchemy/project/examples/example_1/main.py
+0
-1
python-sqlite-sqlalchemy/project/examples/example_2/main.py
python-sqlite-sqlalchemy/project/examples/example_2/main.py
+6
-6
未找到文件。
python-sqlite-sqlalchemy/project/data/author_book_publisher.csv
浏览文件 @
42c65bdb
first_name,last_name,title,publisher
Is
s
ac,Asimov,Foundation,Random House
Is
a
ac,Asimov,Foundation,Random House
Pearl,Buck,The Good Earth,Random House
Pearl,Buck,The Good Earth,Simon & Schuster
Tom,Clancy,The Hunt For Red October,Berkley
...
...
python-sqlite-sqlalchemy/project/data/author_book_publisher.db
浏览文件 @
42c65bdb
无法预览此类型文件
python-sqlite-sqlalchemy/project/examples/example_1/main.py
浏览文件 @
42c65bdb
...
...
@@ -82,7 +82,6 @@ def output_author_hierarchy(data):
authors
=
data
.
assign
(
name
=
data
.
first_name
.
str
.
cat
(
data
.
last_name
,
sep
=
" "
)
)
authors_tree
=
Tree
()
authors_tree
.
create_node
(
"Authors"
,
"authors"
)
for
author
,
books
in
authors
.
groupby
(
"name"
):
...
...
python-sqlite-sqlalchemy/project/examples/example_2/main.py
浏览文件 @
42c65bdb
...
...
@@ -65,7 +65,7 @@ def get_authors_by_publishers(session, ascending=True):
def
get_authors
(
session
):
"""Get a list of author objects"""
"""Get a list of author objects
sorted by last name
"""
return
session
.
query
(
Author
).
order_by
(
Author
.
last_name
).
all
()
...
...
@@ -73,9 +73,9 @@ def add_new_book(session, author_name, book_title, publisher_name):
"""Adds a new book to the system"""
# Get the author's first and last names
first_name
,
last_name
=
author_name
.
split
(
" "
)
first_name
,
_
,
last_name
=
author_name
.
partition
(
" "
)
#
Get the book if it
exists
#
Check if the book
exists
book
=
(
session
.
query
(
Book
)
.
join
(
Author
)
...
...
@@ -92,7 +92,7 @@ def add_new_book(session, author_name, book_title, publisher_name):
if
book
is
not
None
:
return
#
get the book by
the author
#
Check if the book exists for
the author
book
=
(
session
.
query
(
Book
)
.
join
(
Author
)
...
...
@@ -156,8 +156,8 @@ def output_author_hierarchy(authors):
for
author
in
authors
:
author_id
=
f
"
{
author
.
first_name
}
{
author
.
last_name
}
"
authors_tree
.
create_node
(
author_id
,
author_id
,
parent
=
"authors"
)
for
index
,
book
in
enumerate
(
author
.
books
)
:
book_id
=
f
"
{
author_id
}
:
{
book
.
title
}
:
{
index
}
"
for
book
in
author
.
books
:
book_id
=
f
"
{
author_id
}
:
{
book
.
title
}
"
authors_tree
.
create_node
(
book
.
title
,
book_id
,
parent
=
author_id
)
for
publisher
in
book
.
publishers
:
authors_tree
.
create_node
(
publisher
.
name
,
parent
=
book_id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录