Skip to content

Commit

Permalink
v0.1.9.10
Browse files Browse the repository at this point in the history
- Fixing #26
  • Loading branch information
v1a0 committed Jun 16, 2021
1 parent b00f248 commit 2607696
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ If you need most stable version install **sqllex==0.1.9.4**

| Version | Status | Tests, and actions |
| :--------: | :----------------------------: | :---: |
| `0.1.9.9` | ⚠️ unstable <br> ✔️ supported | [![CodeQL](https://github.com/v1a0/sqllex/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/v1a0/sqllex/actions/workflows/codeql-analysis.yml) </br> [![Test Sqlite3x](https://github.com/v1a0/sqllex/actions/workflows/test_sqlite3x.yml/badge.svg?branch=main)](https://github.com/v1a0/sqllex/actions/workflows/test_sqlite3x.yml) </br> [![Upload Python Package](https://github.com/v1a0/sqllex/actions/workflows/python-publish.yml/badge.svg)](https://github.com/v1a0/sqllex/actions/workflows/python-publish.yml) |
| `0.1.9.10` | ⚠️ unstable <br> ✔️ supported | [![CodeQL](https://github.com/v1a0/sqllex/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/v1a0/sqllex/actions/workflows/codeql-analysis.yml) </br> [![Test Sqlite3x](https://github.com/v1a0/sqllex/actions/workflows/test_sqlite3x.yml/badge.svg?branch=main)](https://github.com/v1a0/sqllex/actions/workflows/test_sqlite3x.yml) </br> [![Upload Python Package](https://github.com/v1a0/sqllex/actions/workflows/python-publish.yml/badge.svg)](https://github.com/v1a0/sqllex/actions/workflows/python-publish.yml) |
| `0.1.9.4` | ✔️ stable <br> ✔️ supported | ✔️All passed |
| `<= 0.1.8.12` | ✔️ stable <br> ❌️ outdated | ~ |

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
'sqllex.types',
'sqllex.debug',
],
version='0.1.9.9',
version='0.1.9.10',
license='gpl-3.0',
description='Better than sqlite3',
author='v1a0',
url="https://github.com/v1a0/sqllex",
download_url="https://github.com/V1A0/sqllex/archive/refs/tags/v0.1.9.9.tar.gz",
download_url="https://github.com/V1A0/sqllex/archive/refs/tags/v0.1.9.10.tar.gz",
keywords=['sql', 'sql3', 'sqlite', 'sqlite3', 'sqllex', 'db', 'database', 'easy'],
install_requires=[
'colorama==0.4.4',
Expand Down
13 changes: 9 additions & 4 deletions sqllex/classes/sqlite3x/sqlite3x.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,13 +1506,16 @@ def _insertmany_stmt_(
"""
Parent method for insertmany method
Comment:
args also support numpy.array value
"""

if args:
args = list(filter(bool, args[0])) # removing [] (empty lists from inserting values)
args = list(filter(lambda ar: len(ar) > 0, args[0])) # removing [] (empty lists from inserting values)

if not args: # if args empty after filtering, break the function, yes it'll break
logger.warning("Inserting or updating braked because no values to insert")
if len(args) == 0: # if args empty after filtering, break the function, yes it'll break
logger.warning("insertmany/updatemany failed, due to no values to insert/update")
return

values = list(
Expand Down Expand Up @@ -2138,6 +2141,7 @@ def insertmany(
Name of table
args : Union[List, Tuple]
1'st way set values for insert
P.S: args also support numpy.array value
OR : OrOptionsType
Optional parameter. If INSERT failed, type OrOptionsType
kwargs : Any
Expand Down Expand Up @@ -2428,9 +2432,10 @@ def updatemany(
Name of table
SET : Union[List, Tuple, Mapping]
Values to insert or update
P.S: SET also support numpy.array value
"""

if SET:
if SET is not None:
self._insertmany_stmt_(
TABLE,
SET,
Expand Down
33 changes: 33 additions & 0 deletions tests/numpy_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from numpy import array, nan
from numpy.typing._array_like import ndarray
from sqllex import SQLite3x, TEXT, UNIQUE, INTEGER, REAL


data = array([['World', 2415712510, 318.1, '9.7%', nan],
['United States', 310645827, 949.5, '44.3%',
'Johnson&Johnson, Moderna, Pfizer/BioNTech'],
['India', 252760364, 186.9, '3.5%',
'Covaxin, Covishield, Oxford/AstraZeneca'],
['Brazil', 78906225, 376.7, '11.3%',
'Oxford / AstraZeneca, Oxford/AstraZeneca, Pfizer/BioNTech, Sinovac']])

vaccine_db = SQLite3x('numpy_test.db')

vaccine_db.create_table(
name='Total',
columns={
"Country": [TEXT, UNIQUE],
"Doses_Administered": INTEGER,
"Doses_per_1000": REAL,
"Fully_Vaccinated_Population": TEXT,
"Vaccine_Type_Used": TEXT
},
IF_NOT_EXIST=True
)

vaccine_db.updatemany('Total', data)

vaccine_db.updatemany('Total', array([[],[]]))



0 comments on commit 2607696

Please sign in to comment.