Skip to content

Commit

Permalink
Merge pull request #4 from sqlitecloud/#3-remove-C-dependency
Browse files Browse the repository at this point in the history
#3 remove c dependency
  • Loading branch information
danielebriggi authored May 16, 2024
2 parents 72fc921 + 36c8ce6 commit 25ae065
Show file tree
Hide file tree
Showing 27 changed files with 1,948 additions and 1,476 deletions.
6 changes: 6 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM mcr.microsoft.com/devcontainers/python:3.6-bullseye

ADD https://dl.yarnpkg.com/debian/pubkey.gpg /etc/apt/trusted.gpg.d/yarn.asc

RUN chmod +r /etc/apt/trusted.gpg.d/*.asc && \
echo "deb http://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
34 changes: 34 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/warrenbuckley/codespace-features/sqlite:1": {}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"littlefoxteam.vscode-python-test-adapter",
"jkillian.custom-local-formatters"
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SQLITE_CONNECTION_STRING=sqlitecloud://myhost.sqlite.cloud
SQLITE_USER=admin
SQLITE_PASSWORD=
SQLITE_API_KEY=
SQLITE_HOST=myhost.sqlite.cloud
SQLITE_DB=chinook.sqlite
SQLITE_PORT=8860
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
5 changes: 0 additions & 5 deletions .pylintrc

This file was deleted.

23 changes: 0 additions & 23 deletions Makefile

This file was deleted.

16 changes: 8 additions & 8 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pylint==2.15.6
pytest==7.1.2
mypy==1.6.1
mypy-extensions==1.0.0
typing-extensions==4.8.0
pylint==2.13.9
mypy==0.971
typing-extensions==4.1.1
bump2version==1.0.1
pytest-mock==3.10.0
black==23.7.0
python-dotenv==1.0.0
pytest==7.0.1
pytest-mock==3.6.1
black==22.8.0
python-dotenv==0.20.0
lz4==3.1.10
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lz4==3.1.10
94 changes: 27 additions & 67 deletions samples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading SQLITECLOUD lib from: /Users/sam/projects/codermine/sqlitecloud-sdk/C/libsqcloud.so\n"
]
}
],
"outputs": [],
"source": [
"from sqlitecloud.conn_info import user,password,host,db_name,port\n",
"from sqlitecloud.client import SqliteCloudClient, SqliteCloudAccount"
"import sys\n",
"\n",
"sys.path.append('/workspaces/python/src')\n",
"\n",
"from sqlitecloud.conn_info import user, password, host, db_name, port\n",
"from sqlitecloud.client import SqliteCloudClient\n",
"from sqlitecloud.types import SqliteCloudAccount"
]
},
{
Expand All @@ -40,27 +37,27 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"account = SqliteCloudAccount(user, password, host, db_name, port)\n",
"account = SqliteCloudAccount(user, password, host, db_name, int(port))\n",
"client = SqliteCloudClient(cloud_account=account)\n",
"conn = client.open_connection()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'people'"
"'chinook.sqlite'"
]
},
"execution_count": 3,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -78,17 +75,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"select * from employees;\n"
]
}
],
"outputs": [],
"source": [
"query = \"select * from employees;\"\n",
"result = client.exec_query(query, conn)"
Expand All @@ -103,21 +92,21 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'emp_id': 1, 'emp_name': b'Bobby Tables'}\n",
"{'emp_id': 1, 'emp_name': b'Bobby Tables'}\n",
"{'emp_id': 1, 'emp_name': b'Bobby Tables'}\n",
"{'emp_id': 1, 'emp_name': b'Bobby Tables'}\n",
"{'emp_id': 1, 'emp_name': b'Bobby Tables'}\n",
"{'emp_id': 1, 'emp_name': b'Bobby Tables'}\n",
"{'emp_id': 1, 'emp_name': b'Bobby Tables'}\n",
"{'emp_id': 1, 'emp_name': b'Bobby Tables'}\n"
"{'EmployeeId': '1', 'LastName': 'Adams', 'FirstName': 'Andrew', 'Title': 'General Manager', 'ReportsTo': None, 'BirthDate': '1962-02-18 00:00:00', 'HireDate': '2002-08-14 00:00:00', 'Address': '11120 Jasper Ave NW', 'City': 'Edmonton', 'State': 'AB', 'Country': 'Canada', 'PostalCode': 'T5K 2N1', 'Phone': '+1 (780) 428-9482', 'Fax': '+1 (780) 428-3457', 'Email': '[email protected]'}\n",
"{'EmployeeId': '2', 'LastName': 'Edwards', 'FirstName': 'Nancy', 'Title': 'Sales Manager', 'ReportsTo': '1', 'BirthDate': '1958-12-08 00:00:00', 'HireDate': '2002-05-01 00:00:00', 'Address': '825 8 Ave SW', 'City': 'Calgary', 'State': 'AB', 'Country': 'Canada', 'PostalCode': 'T2P 2T3', 'Phone': '+1 (403) 262-3443', 'Fax': '+1 (403) 262-3322', 'Email': '[email protected]'}\n",
"{'EmployeeId': '3', 'LastName': 'Peacock', 'FirstName': 'Jane', 'Title': 'Sales Support Agent', 'ReportsTo': '2', 'BirthDate': '1973-08-29 00:00:00', 'HireDate': '2002-04-01 00:00:00', 'Address': '1111 6 Ave SW', 'City': 'Calgary', 'State': 'AB', 'Country': 'Canada', 'PostalCode': 'T2P 5M5', 'Phone': '+1 (403) 262-3443', 'Fax': '+1 (403) 262-6712', 'Email': '[email protected]'}\n",
"{'EmployeeId': '4', 'LastName': 'Park', 'FirstName': 'Margaret', 'Title': 'Sales Support Agent', 'ReportsTo': '2', 'BirthDate': '1947-09-19 00:00:00', 'HireDate': '2003-05-03 00:00:00', 'Address': '683 10 Street SW', 'City': 'Calgary', 'State': 'AB', 'Country': 'Canada', 'PostalCode': 'T2P 5G3', 'Phone': '+1 (403) 263-4423', 'Fax': '+1 (403) 263-4289', 'Email': '[email protected]'}\n",
"{'EmployeeId': '5', 'LastName': 'Johnson', 'FirstName': 'Steve', 'Title': 'Sales Support Agent', 'ReportsTo': '2', 'BirthDate': '1965-03-03 00:00:00', 'HireDate': '2003-10-17 00:00:00', 'Address': '7727B 41 Ave', 'City': 'Calgary', 'State': 'AB', 'Country': 'Canada', 'PostalCode': 'T3B 1Y7', 'Phone': '1 (780) 836-9987', 'Fax': '1 (780) 836-9543', 'Email': '[email protected]'}\n",
"{'EmployeeId': '6', 'LastName': 'Mitchell', 'FirstName': 'Michael', 'Title': 'IT Manager', 'ReportsTo': '1', 'BirthDate': '1973-07-01 00:00:00', 'HireDate': '2003-10-17 00:00:00', 'Address': '5827 Bowness Road NW', 'City': 'Calgary', 'State': 'AB', 'Country': 'Canada', 'PostalCode': 'T3B 0C5', 'Phone': '+1 (403) 246-9887', 'Fax': '+1 (403) 246-9899', 'Email': '[email protected]'}\n",
"{'EmployeeId': '7', 'LastName': 'King', 'FirstName': 'Robert', 'Title': 'IT Staff', 'ReportsTo': '6', 'BirthDate': '1970-05-29 00:00:00', 'HireDate': '2004-01-02 00:00:00', 'Address': '590 Columbia Boulevard West', 'City': 'Lethbridge', 'State': 'AB', 'Country': 'Canada', 'PostalCode': 'T1K 5N8', 'Phone': '+1 (403) 456-9986', 'Fax': '+1 (403) 456-8485', 'Email': '[email protected]'}\n",
"{'EmployeeId': '8', 'LastName': 'Callahan', 'FirstName': 'Laura', 'Title': 'IT Staff', 'ReportsTo': '6', 'BirthDate': '1968-01-09 00:00:00', 'HireDate': '2004-03-04 00:00:00', 'Address': '923 7 ST NW', 'City': 'Lethbridge', 'State': 'AB', 'Country': 'Canada', 'PostalCode': 'T1H 1Y8', 'Phone': '+1 (403) 467-3351', 'Fax': '+1 (403) 467-8772', 'Email': '[email protected]'}\n"
]
}
],
Expand All @@ -135,41 +124,12 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"client.disconnect(conn)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can bind values to parametric queries: you can pass parameters as positional values in an array"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ev type: <class 'int'>\n",
"ev type: <class 'str'>\n"
]
}
],
"source": [
"new_connection = client.open_connection()\n",
"result = client.exec_statement(\"select * from employees where emp_id = ? and emp_name = ? \", [1,'Bobby Tables'],conn=new_connection)\n",
"for r in result:\n",
" print(r)\n",
"client.disconnect(conn)"
]
}
],
"metadata": {
Expand All @@ -188,7 +148,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.6.15"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 25ae065

Please sign in to comment.