-
Notifications
You must be signed in to change notification settings - Fork 473
PonyORM tutorial #6531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PonyORM tutorial #6531
Conversation
Online preview: http://cockroach-docs-review.s3-website-us-east-1.amazonaws.com/7fb6dd9eaef3fcbf79290132a82371cd9f6e4d33/ Edited pages: |
Let's add this to 19.2 as well! |
7fb6dd9
to
e8b3bd3
Compare
@awoods187 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM
Reviewed 16 of 16 files at r1.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @apantel)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits
|
||
The code below uses PonyORM to map Python objects and methods to SQL operations. When you run the code as a script, it performs the following operations: | ||
|
||
1. Reads existing account IDs from the bank database. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: bank > bank
$ python3 pony-basic-sample.py | ||
~~~ | ||
|
||
To verify that the table and rows were created successfully, open a new terminal, and start a new session with the built-in SQL client: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove the comma after "terminal"
|
||
<div class="filters filters-big clearfix"> | ||
<a href="build-a-python-app-with-cockroachdb.html"><button style="width: 20%" class="filter-button">Use <strong>psycopg2</strong></button></a> | ||
<a href="build-a-python-app-with-cockroachdb-sqlalchemy.html"><button style="width: 20%" class="filter-button">Use <strong>SQLAlchemy</strong></button></a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: The Use SQLAlchemy
tab looks horizontally off-center in the online preview.
|
||
{% include copy-clipboard.html %} | ||
~~~ shell | ||
$ pip install pony |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Same issue as with Django -- might want to remind users to use pip3
if pip
doesn't work for them.
|
||
## Step 3. Generate a certificate for the `maxroach` user | ||
|
||
Create a certificate and key for the `maxroach` user by running the following command. The code samples will run as this user. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a certificate > Create a client certificate
<section class="filter-content" markdown="1" data-scope="secure"> | ||
|
||
Copy the code below to a file or | ||
<a href="https://raw.githubusercontent.com/cockroachdb/docs/master/_includes/{{page.version.version}}/app/pony-basic-sample.py">download it directly</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code looks weird here but renders okay ¯_(ツ)_/¯
100 | ||
(1 row) | ||
~~~ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code works perfectly!
@@ -0,0 +1,140 @@ | |||
--- | |||
title: Build a Python App with CockroachDB and PonyORM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the comments for the 19.2 doc apply to 20.1
e8b3bd3
to
1fd06f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTR @Amruta-Ranade!
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @Amruta-Ranade and @rafiss)
v19.2/build-a-python-app-with-cockroachdb-pony.md, line 10 at r1 (raw file):
Previously, Amruta-Ranade (Amruta Ranade) wrote…
nit: The
Use SQLAlchemy
tab looks horizontally off-center in the online preview.
Fixed.
v19.2/build-a-python-app-with-cockroachdb-pony.md, line 34 at r1 (raw file):
Previously, Amruta-Ranade (Amruta Ranade) wrote…
nit: Same issue as with Django -- might want to remind users to use
pip3
ifpip
doesn't work for them.
Done.
v19.2/build-a-python-app-with-cockroachdb-pony.md, line 45 at r1 (raw file):
Previously, Amruta-Ranade (Amruta Ranade) wrote…
Create a certificate > Create a client certificate
Done.
v19.2/build-a-python-app-with-cockroachdb-pony.md, line 68 at r1 (raw file):
Previously, Amruta-Ranade (Amruta Ranade) wrote…
nit: bank >
bank
Done.
v19.2/build-a-python-app-with-cockroachdb-pony.md, line 136 at r1 (raw file):
Previously, Amruta-Ranade (Amruta Ranade) wrote…
The code works perfectly!
Great!
v20.1/build-a-python-app-with-cockroachdb-pony.md, line 2 at r1 (raw file):
Previously, Amruta-Ranade (Amruta Ranade) wrote…
All the comments for the 19.2 doc apply to 20.1
Done.
Fixes #6043 .
I tested the code in insecure and secure mode. The code works just fine. Pony implemented a retry decorator that they use for all transactions, which lightens the load on us and on users (thanks Pony!).
Note
I won't merge this until we officially launch support.