Skip to content

Commit

Permalink
Merge pull request #1104 from phenobarbital/refactor-2.7-scylladb
Browse files Browse the repository at this point in the history
bump version of redis
  • Loading branch information
phenobarbital committed May 21, 2024
2 parents 4c1073e + 2afa361 commit 14f803d
Show file tree
Hide file tree
Showing 4 changed files with 408 additions and 72 deletions.
2 changes: 1 addition & 1 deletion asyncdb/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__title__ = "asyncdb"
__description__ = "Library for Asynchronous data source connections \
Collection of asyncio drivers."
__version__ = "2.7.6"
__version__ = "2.7.7"
__author__ = "Jesus Lara"
__author_email__ = "jesuslarag@gmail.com"
__license__ = "BSD"
196 changes: 173 additions & 23 deletions examples/test_rethink.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"db": "troc"
}

data = [
scdata = [
{'inserted_at': iso8601.parse_date('2020-12-09 04:23:52.441312+0000'),
'description': 'TERRE HAUTE-WM - #4235', 'company_id': 1,
'territory_id': 2.0, 'territory_name': '2-Midwest',
Expand Down Expand Up @@ -62,14 +62,178 @@ async def test_connect(event_loop):
print('Check if table already exists: ')
exists = await conn.list_tables()
print('Exists? ', 'sample_scorecard' in exists)
inserted = await conn.insert('sample_scorecard', data)
inserted = await conn.insert('sample_scorecard', scdata)
print('INSERTED: ', inserted)
await conn.drop_table('sample_scorecard')

await conn.db('troc')
_filter = {"company_id": 10, "state_code": "FL"}
# places table
created = await conn.create_table('places', pk='place_id')
data = [
{
"address": "123 Main St",
"city": "Springfield",
"state_code": "IL",
"name": "John Doe",
"place_id": "1",
"company_id": "1001"
},
{
"address": "456 Elm St",
"city": "Hometown",
"state_code": "TX",
"name": "Jane Smith",
"place_id": "2",
"company_id": "1002"
},
{
"address": "789 Oak St",
"city": "Metropolis",
"state_code": "NY",
"name": "Alice Johnson",
"place_id": "3",
"company_id": "1003"
},
{
"address": "101 Maple St",
"city": "Gotham",
"state_code": "NJ",
"name": "Bob Brown",
"place_id": "4",
"company_id": "1004"
},
{
"address": "202 Pine St",
"city": "Smallville",
"state_code": "KS",
"name": "Charlie Davis",
"place_id": "5",
"company_id": "1005"
},
{
"address": "303 Cedar St",
"city": "Star City",
"state_code": "CA",
"name": "Dana White",
"place_id": "6",
"company_id": "1006"
},
{
"address": "404 Birch St",
"city": "Central City",
"state_code": "CO",
"name": "Eve Black",
"place_id": "7",
"company_id": "1007"
},
{
"address": "505 Spruce St",
"city": "Coast City",
"state_code": "FL",
"name": "Frank Green",
"place_id": "8",
"company_id": "1008"
},
{
"address": "606 Walnut St",
"city": "Keystone",
"state_code": "PA",
"name": "Grace Hill",
"place_id": "9",
"company_id": "1009"
},
{
"address": "707 Chestnut St",
"city": "Blüdhaven",
"state_code": "DE",
"name": "Hank Martin",
"place_id": "10",
"company_id": "1010"
},
{
"address": "808 Ash St",
"city": "Midway City",
"state_code": "OH",
"name": "Ivy King",
"place_id": "11",
"company_id": "1011"
},
{
"address": "909 Beech St",
"city": "Gateway City",
"state_code": "OR",
"name": "Jack Lee",
"place_id": "12",
"company_id": "1012"
},
{
"address": "1010 Redwood St",
"city": "Fawcett City",
"state_code": "WI",
"name": "Kara Moore",
"place_id": "13",
"company_id": "1013"
},
{
"address": "1111 Willow St",
"city": "National City",
"state_code": "AZ",
"name": "Leo Taylor",
"place_id": "14",
"company_id": "1014"
},
{
"address": "1212 Poplar St",
"city": "Opal City",
"state_code": "MD",
"name": "Mia Anderson",
"place_id": "15",
"company_id": "1015"
},
{
"address": "1313 Holly St",
"city": "Happy Harbor",
"state_code": "RI",
"name": "Nina Perez",
"place_id": "16",
"company_id": "1016"
},
{
"address": "1414 Magnolia St",
"city": "Hub City",
"state_code": "NM",
"name": "Oscar Brown",
"place_id": "17",
"company_id": "1017"
},
{
"address": "1515 Cypress St",
"city": "Jump City",
"state_code": "VA",
"name": "Paula Davis",
"place_id": "18",
"company_id": "1018"
},
{
"address": "1616 Fir St",
"city": "St. Roch",
"state_code": "LA",
"name": "Quinn Garcia",
"place_id": "19",
"company_id": "1019"
},
{
"address": "1717 Hemlock St",
"city": "Gateway",
"state_code": "MA",
"name": "Ray Harris",
"place_id": "20",
"company_id": "1020"
}
]
await conn.insert('places', data)
# getting data:
_filter = {"state_code": "TX"}
result, error = await conn.query(
'troc_populartimes',
'places',
**_filter,
order_by = ['company_id', 'city'],
limit=10,
Expand All @@ -81,26 +245,12 @@ async def test_connect(event_loop):
pprint(row)
# getting one single row:
site1, error = await conn.queryrow(
'troc_populartimes',
columns=['address', 'city', 'state_code', 'name', 'place_id', 'company_id', 'coordinates'],
place_id='ChIJheKbjENx54gRDpzTZVc0NHk'
'places',
columns=['address', 'city', 'state_code', 'name', 'place_id', 'company_id'],
place_id='3'
)
if not error:
print('ROW ', site1)
site2, error = await conn.queryrow(
'troc_populartimes',
columns=['address', 'city', 'state_code', 'name', 'place_id', 'company_id', 'coordinates'],
place_id='ChIJMYUYxbBGFIgRMbFlFTJWD5g'
)
if not error:
print('ROW ', site2)
# return distance between site1 and 2:
if site1:
p1 = Point(*site1['coordinates'].values())
if site2:
p2 = Point(*site2['coordinates'].values())
distance = await conn.distance(p1, p2, unit='km')
print(f'::: Distance between {p1} and {p2}: {distance} km.')
await conn.drop_database('testing')


Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def readme():
"influxdb==5.3.1",
"influxdb-client[async]==1.39.0",
"pymssql==2.2.11",
"redis==5.0.1",
"redis==5.0.4",
"deltalake==0.17.4",
"duckdb==0.10.2",
],
Expand Down Expand Up @@ -160,8 +160,7 @@ def readme():
"redis": [
"jsonpath-rw==1.4.0",
"jsonpath-rw-ext==1.2.2",
"redis==5.0.1",
"hiredis==2.2.3",
"redis==5.0.4",
"objectpath==0.6.1",
],
"rethinkdb": [
Expand Down Expand Up @@ -245,7 +244,7 @@ def readme():
"aiomcache==0.8.1",
"jsonpath-rw==1.4.0",
"jsonpath-rw-ext==1.2.2",
"redis==5.0.1",
"redis==5.0.4",
"objectpath==0.6.1",
"rethinkdb==2.4.10.post1",
"aiopg==1.4.0",
Expand Down
Loading

0 comments on commit 14f803d

Please sign in to comment.