diff options
| author | Simeon Simeonov | 2021-03-16 11:03:38 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2021-03-16 11:03:38 +0100 |
| commit | 85c1bd41d6b3b985bb6794ebe066128c51e7c8fd (patch) | |
| tree | 9cd33b733b1e11b8fedf88c7e31213d29c4cb9ac | |
| parent | f5b94931274107ae70587a4c1ac0c3756b7f16ab (diff) | |
Improve reveal.js/sqlalchemy.html and start working on the Statnett theme
| -rw-r--r-- | reveal.js/dist/theme/statnett.css | 12 | ||||
| -rw-r--r-- | reveal.js/dist/theme/statnett.svg | 1 | ||||
| -rwxr-xr-x | reveal.js/sqlalchemy.html | 17 |
3 files changed, 18 insertions, 12 deletions
diff --git a/reveal.js/dist/theme/statnett.css b/reveal.js/dist/theme/statnett.css index 5f5ab00..5c6d6af 100644 --- a/reveal.js/dist/theme/statnett.css +++ b/reveal.js/dist/theme/statnett.css | |||
| @@ -40,11 +40,13 @@ section.has-dark-background, section.has-dark-background h1, section.has-dark-ba | |||
| 40 | 40 | ||
| 41 | .reveal-viewport { | 41 | .reveal-viewport { |
| 42 | background: #F0F1EB; | 42 | background: #F0F1EB; |
| 43 | background-image: url("statnett.svg"); | ||
| 44 | background-repeat: no-repeat; | ||
| 43 | background-color: #F0F1EB; } | 45 | background-color: #F0F1EB; } |
| 44 | 46 | ||
| 45 | .reveal { | 47 | .reveal { |
| 46 | font-family: "Palatino Linotype", "Book Antiqua", Palatino, FreeSerif, serif; | 48 | font-family: "Palatino Linotype", "Book Antiqua", Palatino, FreeSerif, serif; |
| 47 | font-size: 22px; | 49 | font-size: 24px; |
| 48 | font-weight: normal; | 50 | font-weight: normal; |
| 49 | color: #000; } | 51 | color: #000; } |
| 50 | 52 | ||
| @@ -117,8 +119,8 @@ section.has-dark-background, section.has-dark-background h1, section.has-dark-ba | |||
| 117 | .reveal img, | 119 | .reveal img, |
| 118 | .reveal video, | 120 | .reveal video, |
| 119 | .reveal iframe { | 121 | .reveal iframe { |
| 120 | max-width: 96%; | 122 | max-width: 95%; |
| 121 | max-height: 96%; } | 123 | max-height: 95%; } |
| 122 | 124 | ||
| 123 | .reveal strong, | 125 | .reveal strong, |
| 124 | .reveal b { | 126 | .reveal b { |
| @@ -179,10 +181,10 @@ section.has-dark-background, section.has-dark-background h1, section.has-dark-ba | |||
| 179 | .reveal pre { | 181 | .reveal pre { |
| 180 | display: block; | 182 | display: block; |
| 181 | position: relative; | 183 | position: relative; |
| 182 | width: 95%; | 184 | width: 90%; |
| 183 | margin: 20px auto; | 185 | margin: 20px auto; |
| 184 | text-align: left; | 186 | text-align: left; |
| 185 | font-size: 0.60em; | 187 | font-size: 0.55em; |
| 186 | font-family: monospace; | 188 | font-family: monospace; |
| 187 | line-height: 1.1em; | 189 | line-height: 1.1em; |
| 188 | word-wrap: break-word; } | 190 | word-wrap: break-word; } |
diff --git a/reveal.js/dist/theme/statnett.svg b/reveal.js/dist/theme/statnett.svg new file mode 100644 index 0000000..7f66194 --- /dev/null +++ b/reveal.js/dist/theme/statnett.svg | |||
| @@ -0,0 +1 @@ | |||
| <svg xmlns="http://www.w3.org/2000/svg" width="212" height="44" viewBox="0 0 53.446 11.066"><defs><clipPath id="a"><path d="M45.355 788.926h38.213v7.609H45.355z" /></clipPath></defs><g clip-path="url(#a)" transform="matrix(1.3848 0 0 -1.3848 -62.543 1103.3)" stroke-width=".255"><path d="M47.257 791.534c.04-.859.573-1.136 1.38-1.136.574 0 1.168.205 1.168.747 0 .644-1.045.767-2.098 1.064-1.043.296-2.137.768-2.137 2.107 0 1.596 1.605 2.22 2.976 2.22 1.452 0 2.915-.706 2.925-2.353h-1.902c.03.665-.593.88-1.177.88-.41 0-.92-.144-.92-.624 0-.563 1.053-.665 2.117-.962 1.054-.296 2.117-.787 2.117-2.107 0-1.85-1.575-2.445-3.181-2.445-1.677 0-3.16.737-3.171 2.61zM55.136 793.263h-1.074v-2.414c0-.42.245-.511.624-.511.143 0 .296.02.45.02v-1.278c-.318-.011-.634-.051-.951-.051-1.483 0-1.862.429-1.862 1.872v5.093h1.739v-1.606h1.074zM58.068 790c.828 0 1.105.47 1.064 1.565-.246-.154-.696-.185-1.074-.286-.39-.092-.716-.256-.716-.676 0-.43.337-.603.726-.603m-2.25 2.75c.03.697.358 1.147.828 1.424.471.265 1.085.367 1.687.367 1.26 0 2.476-.276 2.476-1.78v-2.321c0-.451 0-.94.204-1.36h-1.749a2.064 2.064 0 0 0-.102.5c-.45-.47-1.114-.654-1.749-.654-1.012 0-1.81.51-1.81 1.606 0 1.729 1.882 1.596 3.09 1.84.295.063.46.165.46.492 0 .399-.48.552-.84.552-.48 0-.787-.214-.869-.665zM64.451 793.263h-1.074v-2.414c0-.42.245-.511.624-.511.143 0 .296.02.45.02v-1.278c-.317-.011-.634-.051-.952-.051-1.483 0-1.861.429-1.861 1.872v5.093h1.739v-1.606h1.074z" fill="#636466" /><path d="M65.34 794.393h1.686v-.726h.02c.318.542 1.034.88 1.667.88 1.77 0 1.913-1.29 1.913-2.056v-3.406h-1.738v2.568c0 .725.082 1.462-.869 1.462-.655 0-.94-.553-.94-1.136v-2.894h-1.74zM75.087 792.286c-.03.594-.45 1.085-1.034 1.085-.613 0-1.022-.44-1.125-1.085zm-2.159-.972c.032-.725.451-1.206 1.187-1.206.42 0 .83.194.993.583h1.626c-.317-1.228-1.452-1.76-2.639-1.76-1.729 0-2.905 1.044-2.905 2.824 0 1.626 1.3 2.792 2.863 2.792 1.903 0 2.855-1.432 2.773-3.233zM80.2 793.268h-1.073v-2.414c0-.42.246-.511.624-.511.142 0 .296.02.45.02v-1.278c-.317-.011-.635-.052-.951-.052-1.483 0-1.862.43-1.862 1.873v5.093h1.739v-1.606H80.2zM83.568 793.268h-1.074v-2.414c0-.42.245-.511.624-.511.143 0 .297.02.45.02v-1.278c-.317-.011-.634-.052-.952-.052-1.483 0-1.861.43-1.861 1.873v5.093h1.739v-1.606h1.074z" fill="#ed1c24" /></g></svg> \ No newline at end of file | |||
diff --git a/reveal.js/sqlalchemy.html b/reveal.js/sqlalchemy.html index 578fc13..6acd9b7 100755 --- a/reveal.js/sqlalchemy.html +++ b/reveal.js/sqlalchemy.html | |||
| @@ -48,7 +48,7 @@ | |||
| 48 | <h2>What is SQLAlchemy?</h2> | 48 | <h2>What is SQLAlchemy?</h2> |
| 49 | </br> | 49 | </br> |
| 50 | <p><em>SQLAlchemy</em> is a Python library created by Mike Bayer to provide a high-level Pythonic interface to RDBMS such as <em>PostgreSQL</em>, <em>SQLite</em>, <em>MySQL</em>, <em>Oracle</em>, <em>DB2</em>.</p> | 50 | <p><em>SQLAlchemy</em> is a Python library created by Mike Bayer to provide a high-level Pythonic interface to RDBMS such as <em>PostgreSQL</em>, <em>SQLite</em>, <em>MySQL</em>, <em>Oracle</em>, <em>DB2</em>.</p> |
| 51 | <p><em>SQLAlchemy</em> includes RDBMS-independent SQL expression language and an <em>object-relational mapper (ORM)</em>.</p> | 51 | <p><em>SQLAlchemy</em> includes RDBMS-independent <em>SQL expression language</em> and an <em>object-relational mapper (ORM)</em>.</p> |
| 52 | </section> | 52 | </section> |
| 53 | 53 | ||
| 54 | <section> | 54 | <section> |
| @@ -59,7 +59,7 @@ | |||
| 59 | <li><p>portability - the programming interface is independent of the type of RDBMS and connector used</p></li> | 59 | <li><p>portability - the programming interface is independent of the type of RDBMS and connector used</p></li> |
| 60 | <li><p>security - no more SQL injections</p></li> | 60 | <li><p>security - no more SQL injections</p></li> |
| 61 | <li><p>abstraction - no need to bother with complex JOINs</p></li> | 61 | <li><p>abstraction - no need to bother with complex JOINs</p></li> |
| 62 | <li><p>object-orientation - you work with objects and NOT tables and rows</p></li> | 62 | <li><p>object-orientation - you work with objects instead of tables and rows</p></li> |
| 63 | <li><p>performance - exploits the likehood of reusing a particular query</p></li> | 63 | <li><p>performance - exploits the likehood of reusing a particular query</p></li> |
| 64 | <li><p>flexibility - you can override almost anything</p></li> | 64 | <li><p>flexibility - you can override almost anything</p></li> |
| 65 | <li><p>0.0125 karma points for each MB transferred (2021)</p></li> | 65 | <li><p>0.0125 karma points for each MB transferred (2021)</p></li> |
| @@ -72,9 +72,9 @@ | |||
| 72 | <ul> | 72 | <ul> |
| 73 | <li><em>Engine</em>- manages the connection pool and the RDBMS-independent SQL dialect layer</li> | 73 | <li><em>Engine</em>- manages the connection pool and the RDBMS-independent SQL dialect layer</li> |
| 74 | <li><em>MetaData</em> - used to collect and organize information about your table layout (schema)</li> | 74 | <li><em>MetaData</em> - used to collect and organize information about your table layout (schema)</li> |
| 75 | <li><em>Session</em> - establishes all conversations with the RDBMS and represents a "holding zone" for all the objects which you've loaded or associated with it during its lifespan</li> | ||
| 76 | <li><em>SQL expression language</em> - provides an API to execute your queries and updates against your tables, all from Python, and all in a database-independent way (low-level interface)</li> | 75 | <li><em>SQL expression language</em> - provides an API to execute your queries and updates against your tables, all from Python, and all in a database-independent way (low-level interface)</li> |
| 77 | <li><em>ORM</em> - provides a convenient way to add database persistence to your Python objects withoutrequiring you to design your objects around the database, or the database around the objects (high-level interface)</li> | 76 | <li><em>ORM</em> - provides a convenient way to add database persistence to your Python objects without requiring you to design your objects around the database, or the database around the objects (high-level interface)</li> |
| 77 | <li><em>Session</em> - establishes all conversations with the RDBMS and represents a "holding zone" for all the objects which you've loaded or associated with it during its lifespan</li> | ||
| 78 | </ul> | 78 | </ul> |
| 79 | <img src="images/sqlalchemy/sqla_arch.png"></img> | 79 | <img src="images/sqlalchemy/sqla_arch.png"></img> |
| 80 | </section> | 80 | </section> |
| @@ -86,6 +86,7 @@ | |||
| 86 | <code class="python" data-trim data-line-numbers type="text/template"> | 86 | <code class="python" data-trim data-line-numbers type="text/template"> |
| 87 | import sqlalchemy | 87 | import sqlalchemy |
| 88 | sqlalchemy.__version__ | 88 | sqlalchemy.__version__ |
| 89 | # Out: '1.3.23' | ||
| 89 | 90 | ||
| 90 | from sqlalchemy import create_engine | 91 | from sqlalchemy import create_engine |
| 91 | 92 | ||
| @@ -95,7 +96,6 @@ | |||
| 95 | # and driver the name of a DBAPI, such as psycopg2, pyodbc, cx_oracle | 96 | # and driver the name of a DBAPI, such as psycopg2, pyodbc, cx_oracle |
| 96 | # The echo flag is a shortcut to setting up SQLAlchemy logging, | 97 | # The echo flag is a shortcut to setting up SQLAlchemy logging, |
| 97 | # which is accomplished via Python’s standard logging module. | 98 | # which is accomplished via Python’s standard logging module. |
| 98 | # With it enabled, we’ll see all the generated SQL produced. | ||
| 99 | # engine = create_engine("sqlite:///library.db", echo=True) | 99 | # engine = create_engine("sqlite:///library.db", echo=True) |
| 100 | engine = create_engine("sqlite:///:memory:", echo=True) | 100 | engine = create_engine("sqlite:///:memory:", echo=True) |
| 101 | 101 | ||
| @@ -296,7 +296,8 @@ | |||
| 296 | session.query(Book).join(Author).filter(Author.name == "Richard Dawkins").all() | 296 | session.query(Book).join(Author).filter(Author.name == "Richard Dawkins").all() |
| 297 | session.query(Book).\ | 297 | session.query(Book).\ |
| 298 | from_statement("SELECT b.* FROM books b, authors a WHERE b.author_id = a.author_id AND a.name=:name").\ | 298 | from_statement("SELECT b.* FROM books b, authors a WHERE b.author_id = a.author_id AND a.name=:name").\ |
| 299 | params(name="Richard Dawkins").all() | 299 | params(name="Richard Dawkins").all() |
| 300 | session.query(Book).filter(Book.author == author_1).all() | ||
| 300 | </code> | 301 | </code> |
| 301 | </pre> | 302 | </pre> |
| 302 | </section> | 303 | </section> |
| @@ -336,6 +337,7 @@ | |||
| 336 | # Out: [<__main__.Book at 0x7f132bdf0130>] | 337 | # Out: [<__main__.Book at 0x7f132bdf0130>] |
| 337 | # WHERE (abs(books.book_id) > ?) IS 1 ... in the case of func.abs | 338 | # WHERE (abs(books.book_id) > ?) IS 1 ... in the case of func.abs |
| 338 | 339 | ||
| 340 | # with Pandas | ||
| 339 | df = pd.read_sql_table("my_table", con=session.get_bind()) # or con=engine | 341 | df = pd.read_sql_table("my_table", con=session.get_bind()) # or con=engine |
| 340 | 342 | ||
| 341 | df = pd.read_sql_query(query.statement, engine) | 343 | df = pd.read_sql_query(query.statement, engine) |
| @@ -370,7 +372,8 @@ | |||
| 370 | // Learn about plugins: https://revealjs.netlify.app/plugins/ | 372 | // Learn about plugins: https://revealjs.netlify.app/plugins/ |
| 371 | plugins: [ RevealZoom, RevealNotes, RevealSearch, RevealMarkdown, RevealHighlight ] | 373 | plugins: [ RevealZoom, RevealNotes, RevealSearch, RevealMarkdown, RevealHighlight ] |
| 372 | }); | 374 | }); |
| 373 | 375 | Reveal.configure({ pdfSeparateFragments: false }); | |
| 376 | |||
| 374 | </script> | 377 | </script> |
| 375 | 378 | ||
| 376 | </body> | 379 | </body> |
