Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .copyrightconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ startyear: 2023
# - Use sparingly (third_party, generated, binary assets)
# - Dotfiles already skipped automatically
# Enable by removing the leading '# ' from the next line and editing values.
filesexcluded: .github/*, *.md, Jenkinsfile, gradle/*, *.yml, *.gradle, *.properties, gradlew, gradlew.bat, CODEOWNERS, *.lock, *.toml, *.md, *version, *.json
filesexcluded: .github/*, *.md, Jenkinsfile, gradle/*, *.yml, *.gradle, *.properties, gradlew, gradlew.bat, CODEOWNERS, *.lock, *.toml, *.md, *version, *.json, *.ipynb
20 changes: 12 additions & 8 deletions examples/python-blog-post.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@
"# Change this if needed to point to your MarkLogic instance.\n",
"base_url = \"http://localhost\"\n",
"\n",
"import json\n",
"import os\n",
"from getpass import getpass\n",
"import requests\n",
"from requests.auth import HTTPDigestAuth\n",
"\n",
"# The admin account that can be used to create a new user and role.\n",
"adminUser = \"admin\"\n",
"adminPassword = \"admin\"\n",
"# The admin user is read from the environment variable MARKLOGIC_ADMIN_USER, or defaults to \"admin\".\n",
"# Passwords are read from environment variables, or prompted for if not set.\n",
"adminUser = os.environ.get(\"MARKLOGIC_ADMIN_USER\", \"admin\")\n",
"adminPassword = os.environ.get(\"MARKLOGIC_ADMIN_PASSWORD\") or getpass(\"MarkLogic admin password: \")\n",
"\n",
"# The user to create which will be used for all of the examples.\n",
"user = \"python-blog-user\"\n",
"password = \"pyth0n\"\n",
"password = os.environ.get(\"PYTHON_BLOG_USER_PASSWORD\") or getpass(\"Password for the new example user: \")\n",
"role_name = \"python-blog-role\"\n",
"\n",
"import json\n",
"import requests\n",
"from requests.auth import HTTPDigestAuth\n",
"\n",
"# The App-Services app server in your MarkLogic instance is assumed to be on port 8000 and to require either 'digest' \n",
"# or 'digestbasic' authentication. If the app server uses a different kind of authentication, you will need to modify \n",
"# the two lines below that set the 'auth' fields for the admin and user sessions. The 'admin_session' is also used to \n",
Expand Down Expand Up @@ -88,7 +92,7 @@
"source": [
"# Load 500 JSON employee documents into the Documents database.\n",
"\n",
"r = requests.get(\"https://raw.githubusercontent.com/marklogic/marklogic-spark-connector/master/src/test/resources/500-employees.json\")\n",
"r = requests.get(\"https://raw.githubusercontent.com/marklogic/marklogic-spark-connector/master/marklogic-spark-connector/src/test/resources/500-employees.json\")\n",
"\n",
"for employee in json.loads(r.text):\n",
" user_session.put(\n",
Expand Down
15 changes: 12 additions & 3 deletions examples/release-1.1-examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
"# Create an instance of the MarkLogic Python client, pointing at the out-of-the-box Documents database.\n",
"\n",
"from marklogic import Client\n",
"client = Client(\"http://localhost:8000\", digest=(\"python-user\", \"pyth0n\"))"
"import os\n",
"from getpass import getpass\n",
"\n",
"# Credentials are read from environment variables, or prompted for if not set.\n",
"ml_user = os.environ.get(\"MARKLOGIC_USER\", \"python-user\")\n",
"ml_password = os.environ.get(\"MARKLOGIC_PASSWORD\") or getpass(\"MarkLogic password: \")\n",
"client = Client(\"http://localhost:8000\", digest=(ml_user, ml_password))"
]
},
{
Expand Down Expand Up @@ -66,7 +72,7 @@
"from marklogic.documents import Document, DefaultMetadata\n",
"import requests\n",
"import json\n",
"r = requests.get('https://raw.githubusercontent.com/marklogic/marklogic-spark-connector/master/src/test/resources/500-employees.json')\n",
"r = requests.get('https://raw.githubusercontent.com/marklogic/marklogic-spark-connector/master/marklogic-spark-connector/src/test/resources/500-employees.json')\n",
"\n",
"docs = [\n",
" DefaultMetadata(permissions={\"rest-reader\": [\"read\", \"update\"]}, collections=[\"employee\"])\n",
Expand Down Expand Up @@ -185,7 +191,10 @@
"# Create a Spark DataFrame via a MarkLogic Optic query.\n",
"\n",
"df = spark.read.format(\"marklogic\") \\\n",
" .option(\"spark.marklogic.client.uri\", \"python-user:pyth0n@localhost:8000\") \\\n",
" .option(\"spark.marklogic.client.host\", \"localhost\") \\\n",
" .option(\"spark.marklogic.client.port\", \"8000\") \\\n",
" .option(\"spark.marklogic.client.username\", ml_user) \\\n",
" .option(\"spark.marklogic.client.password\", ml_password) \\\n",
" .option(\"spark.marklogic.read.opticQuery\", \"op.fromView('example', 'employee', '')\") \\\n",
" .load()\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"action": "http://marklogic.com/xdmp/privileges/rest-writer",
"kind": "execute"
},
{
"privilege-name": "any-uri",
"action": "http://marklogic.com/xdmp/privileges/any-uri",
"kind": "execute"
},
{
"privilege-name": "xdbc:eval",
"action": "http://marklogic.com/xdmp/privileges/xdbc-eval",
Expand Down
Loading