1
00:00:00,780 --> 00:00:09,120
Hi, welcome back in this video, you learn how to create a program which creates this PDAF table out

2
00:00:09,120 --> 00:00:15,000
of the school database, so that's the output we will generate.

3
00:00:15,630 --> 00:00:25,260
So I'm going to do that and create the program that generates that -- again database the Déby's

4
00:00:26,100 --> 00:00:27,840
database we'll be working on.

5
00:00:28,230 --> 00:00:31,770
I give you this in the first video of this section.

6
00:00:32,130 --> 00:00:39,900
So we establish a connection to the database and we create a cursor objects in here.

7
00:00:40,950 --> 00:00:51,360
And then we'll be using the F PDF library from a PDF imports of PDF PDAF.

8
00:00:51,810 --> 00:00:59,070
We did convert this library previously in the course in the section about working with PDF files.

9
00:00:59,400 --> 00:01:03,090
So you learn there how to generate PDF files via Python.

10
00:01:03,450 --> 00:01:07,230
So we're going to make use of that knowledge in this video.

11
00:01:09,660 --> 00:01:17,210
FPGA of basically has this cellular structure in the PDF.

12
00:01:17,220 --> 00:01:23,100
So you add cells, you add text in those cells to create the PDF.

13
00:01:23,430 --> 00:01:29,280
So I'm not going to go through details of basically what we want to do is we want to iterate over the

14
00:01:29,280 --> 00:01:37,410
rows of our database table and create a cell for each element in the role.

15
00:01:38,310 --> 00:01:41,340
So for that, we need two pieces of information.

16
00:01:41,580 --> 00:01:47,100
We need the least of columns and then we need the rows for each.

17
00:01:48,170 --> 00:01:56,990
Records the values of each row to give the names of the columns you want to execute and ask you a query.

18
00:01:57,290 --> 00:02:11,330
So pointing to the current object and executes pragma table in full and in parentheses, you place the

19
00:02:11,330 --> 00:02:12,680
name of the table.

20
00:02:13,550 --> 00:02:16,970
So we're getting info from that table.

21
00:02:17,600 --> 00:02:25,850
And then if you create a variable columns, that's a single ticker and fetch what cursor has at the

22
00:02:25,850 --> 00:02:26,370
moment.

23
00:02:26,810 --> 00:02:28,580
And then print out columns.

24
00:02:30,290 --> 00:02:30,920
And you're wrong.

25
00:02:40,340 --> 00:02:41,420
And that's the outputs.

26
00:02:41,600 --> 00:02:44,390
It's a list of tips and each to pull.

27
00:02:46,280 --> 00:02:56,470
Is representing a column, so that is an index of a column, so we have zero one, two or three columns

28
00:02:56,480 --> 00:02:59,990
and the address column has this index of zero.

29
00:03:00,380 --> 00:03:09,200
It's of text types of data or texts and not integers, as is the case of ACE and so as and as integer

30
00:03:09,330 --> 00:03:09,980
other types.

31
00:03:10,370 --> 00:03:13,010
And we have some other column attributes here.

32
00:03:13,130 --> 00:03:14,660
We are not interested on those.

33
00:03:14,840 --> 00:03:16,790
We only want to extract that.

34
00:03:18,460 --> 00:03:25,710
This is how we extract that name of the column, we iterate for column in columns.

35
00:03:27,690 --> 00:03:38,370
And if you print column index one, so that has an index of zero in, that's simple in that, first

36
00:03:38,370 --> 00:03:41,780
of all, that is an index of one index, two and so on.

37
00:03:41,790 --> 00:03:45,030
So we want the item with index one wrong.

38
00:03:45,030 --> 00:03:45,360
That's.

39
00:03:45,720 --> 00:03:52,980
And so we get the column names only address domain ason, but instead of putting bring them out, we

40
00:03:52,980 --> 00:03:57,900
want to insert those columns in the PDF.

41
00:03:58,260 --> 00:04:04,170
But first, we want to we want to create a PDF object using PDF.

42
00:04:08,060 --> 00:04:20,269
Orientation of the PDF is P for portrait, the units are p t for points of as a common unit used in

43
00:04:20,959 --> 00:04:25,280
font sizes and formats, perhaps a for.

44
00:04:29,630 --> 00:04:37,220
And let's add the first page, we're using the ads page Meffert at page event as you iterate over the

45
00:04:37,220 --> 00:04:45,560
columns, you want to see PGA of the said funds, so said the forms of the first sale of the first texts

46
00:04:45,560 --> 00:04:47,270
you want to add to the PDF.

47
00:04:51,720 --> 00:04:56,820
Family is perhaps times and style.

48
00:04:59,660 --> 00:05:09,980
Maybe for the column names, you want a bold and the size or 14 should do it, then the next row on

49
00:05:10,260 --> 00:05:20,090
this four block is part of the cell with the width of 100 height of 25.

50
00:05:20,120 --> 00:05:22,370
So these are in point units.

51
00:05:23,480 --> 00:05:33,230
And the text of this cell is column one, and we want a border of one as well.

52
00:05:33,740 --> 00:05:36,410
So we want the cell to have a border around.

53
00:05:36,860 --> 00:05:38,780
Otherwise, it will look like text.

54
00:05:38,810 --> 00:05:40,400
It will not look like a table.

55
00:05:41,210 --> 00:05:47,860
Once you're done with, that's exit the loop and say PDA of that old puts.

56
00:05:48,270 --> 00:05:53,570
That's a method that will generate the PDF file of the actual PDF file.

57
00:05:54,770 --> 00:06:02,030
Let's see also that PDF as the path of the file run and output, the PDF will be created.

58
00:06:02,360 --> 00:06:03,560
So so far, so good.

59
00:06:06,240 --> 00:06:10,770
Perhaps 30 for the size, for the height or the cell.

60
00:06:14,760 --> 00:06:16,500
So now we have more space.

61
00:06:18,560 --> 00:06:21,830
Then we need to keep adding Rose.

62
00:06:21,860 --> 00:06:24,530
No, the actual records of the table.

63
00:06:26,350 --> 00:06:33,660
To do that, we need to create another full loop, which this time iterate its role in roles.

64
00:06:33,670 --> 00:06:34,240
But what are you?

65
00:06:34,360 --> 00:06:35,380
What is rules?

66
00:06:35,590 --> 00:06:41,680
Well, the rules should be a lease of tipples, which we will get from could execute.

67
00:06:44,170 --> 00:06:50,020
And we run the S-curve query, which is the usual select all from

68
00:06:52,330 --> 00:06:53,550
eyepiece.

69
00:06:53,920 --> 00:06:55,540
Yeah, that's it.

70
00:06:56,470 --> 00:07:00,710
And the rules will be curved that fetch all.

71
00:07:01,450 --> 00:07:03,580
And then you iterate over the rows.

72
00:07:04,090 --> 00:07:05,990
Perhaps we want the same format.

73
00:07:06,880 --> 00:07:07,420
Right?

74
00:07:08,170 --> 00:07:12,370
So I'm going to paste that in there, indent.

75
00:07:16,700 --> 00:07:24,500
And maybe not bold, so I'll remove the style to keep it normal and then PDAF that.

76
00:07:24,740 --> 00:07:32,510
So again, you have the same parameters should do it's age equal to 30 to 60.

77
00:07:33,230 --> 00:07:35,330
This time is going to be.

78
00:07:36,080 --> 00:07:44,990
Well, the rules have multiple values, so one rule has the value for the address, the value for the

79
00:07:45,320 --> 00:07:47,860
domain and the value for the Ascend.

80
00:07:47,860 --> 00:07:56,090
And so therefore, what we want to do is we want to have another full loop here, which ETRADE's so

81
00:07:56,090 --> 00:08:02,870
four elements in a row in each row iterates over the values of each room.

82
00:08:04,430 --> 00:08:07,520
So then we intend that under here.

83
00:08:08,720 --> 00:08:14,360
In that case, Texae will be the element variable.

84
00:08:15,410 --> 00:08:22,010
So we add elements of the element border is equal to one.

85
00:08:22,880 --> 00:08:23,690
Let's run this.

86
00:08:23,690 --> 00:08:27,920
We need to do a few fixes there both.

87
00:08:27,920 --> 00:08:30,800
Let's take things step by step as usual.

88
00:08:31,550 --> 00:08:33,620
So the first error we get is stupid.

89
00:08:33,620 --> 00:08:35,690
Error in object has no attributes.

90
00:08:35,690 --> 00:08:39,289
Replace in line 24 in here.

91
00:08:40,190 --> 00:08:51,560
So I think that this text parameter of this expects a string as inputs, but in the total we have as

92
00:08:51,590 --> 00:08:53,120
and which is an integer.

93
00:08:53,330 --> 00:08:57,580
So we you want to convert everything into a string.

94
00:08:58,070 --> 00:09:02,090
So apply this to our methods and you should be good to go.

95
00:09:03,560 --> 00:09:03,810
Yeah.

96
00:09:04,250 --> 00:09:09,200
Let's see the data and notes exactly what we were looking for.

97
00:09:10,950 --> 00:09:14,060
So we should break the line in here.

98
00:09:14,540 --> 00:09:15,710
How do we break the line?

99
00:09:17,120 --> 00:09:25,090
Well, by using so off of the columns, after you iterate over the columns, exit the loop and apply

100
00:09:25,100 --> 00:09:26,660
PDF the l n.

101
00:09:28,350 --> 00:09:29,100
Wrong again.

102
00:09:32,860 --> 00:09:34,010
Yeah, looks better.

103
00:09:34,070 --> 00:09:43,630
So the first row is under the row of the columns, but then the second row is not, so we want to break

104
00:09:43,630 --> 00:09:45,520
the line also.

105
00:09:46,550 --> 00:09:55,310
After the first row is written, so we iterate for row in rows and then just here.

106
00:09:56,120 --> 00:10:06,650
So one indentation level below the first loop we see PGA of the tail and run again.

107
00:10:09,580 --> 00:10:11,470
And that's the final output.

108
00:10:13,240 --> 00:10:16,990
So that's a table and that's a complete code.

109
00:10:17,440 --> 00:10:20,200
Thank you for following, and I'll talk to you in the next videos.

