ruff lint fix

This commit is contained in:
pedrocarlo 2025-06-19 16:59:49 -03:00
parent 50c8b2ca2e
commit 80ccca8827
29 changed files with 375 additions and 434 deletions

View file

@ -1,9 +1,10 @@
#!/usr/bin/env python3
from cli_tests.test_limbo_cli import TestLimboShell
from pathlib import Path
import time
import os
import time
from pathlib import Path
from cli_tests import console
from cli_tests.test_limbo_cli import TestLimboShell
def test_basic_queries():
@ -62,7 +63,7 @@ def test_joins():
shell.run_test(
"file-cross-join",
"select * from users, products limit 1;",
"1|Jamie|Foster|dylan00@example.com|496-522-9493|62375 Johnson Rest Suite 322|West Lauriestad|IL|35865|94|1|hat|79.0",
"1|Jamie|Foster|dylan00@example.com|496-522-9493|62375 Johnson Rest Suite 322|West Lauriestad|IL|35865|94|1|hat|79.0", # noqa: E501
)
shell.quit()
@ -76,7 +77,7 @@ def test_left_join_self():
shell.run_test(
"file-left-join-self",
"select u1.first_name as user_name, u2.first_name as neighbor_name from users u1 left join users as u2 on u1.id = u2.id + 1 limit 2;",
"select u1.first_name as user_name, u2.first_name as neighbor_name from users u1 left join users as u2 on u1.id = u2.id + 1 limit 2;", # noqa: E501
"Jamie|\nCindy|Jamie",
)
shell.quit()
@ -99,9 +100,7 @@ def test_switch_back_to_in_memory():
shell.run_test("open-testing-db-file", ".open testing/testing.db", "")
# Then switch back to :memory:
shell.run_test("switch-back", ".open :memory:", "")
shell.run_test(
"schema-in-memory", ".schema users", "-- Error: Table 'users' not found."
)
shell.run_test("schema-in-memory", ".schema users", "-- Error: Table 'users' not found.")
shell.quit()
@ -172,9 +171,7 @@ SELECT 2;"""
def test_comments():
shell = TestLimboShell()
shell.run_test("single-line-comment", "-- this is a comment\nSELECT 1;", "1")
shell.run_test(
"multi-line-comments", "-- First comment\n-- Second comment\nSELECT 2;", "2"
)
shell.run_test("multi-line-comments", "-- First comment\n-- Second comment\nSELECT 2;", "2")
shell.run_test("block-comment", "/*\nMulti-line block comment\n*/\nSELECT 3;", "3")
shell.run_test(
"inline-comments",
@ -187,9 +184,7 @@ def test_comments():
def test_import_csv():
shell = TestLimboShell()
shell.run_test("memory-db", ".open :memory:", "")
shell.run_test(
"create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", ""
)
shell.run_test("create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", "")
shell.run_test(
"import-csv-no-options",
".import --csv ./testing/test_files/test.csv csv_table",
@ -206,9 +201,7 @@ def test_import_csv():
def test_import_csv_verbose():
shell = TestLimboShell()
shell.run_test("open-memory", ".open :memory:", "")
shell.run_test(
"create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", ""
)
shell.run_test("create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", "")
shell.run_test(
"import-csv-verbose",
".import --csv -v ./testing/test_files/test.csv csv_table",
@ -225,9 +218,7 @@ def test_import_csv_verbose():
def test_import_csv_skip():
shell = TestLimboShell()
shell.run_test("open-memory", ".open :memory:", "")
shell.run_test(
"create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", ""
)
shell.run_test("create-csv-table", "CREATE TABLE csv_table (c1 INT, c2 REAL, c3 String);", "")
shell.run_test(
"import-csv-skip",
".import --csv --skip 1 ./testing/test_files/test.csv csv_table",
@ -250,51 +241,33 @@ def test_update_with_limit():
limbo.run_test("update-limit", "UPDATE t SET a = 10 LIMIT 1;", "")
limbo.run_test("update-limit-result", "SELECT COUNT(*) from t WHERE a = 10;", "1")
limbo.run_test("update-limit-zero", "UPDATE t SET a = 100 LIMIT 0;", "")
limbo.run_test(
"update-limit-zero-result", "SELECT COUNT(*) from t WHERE a = 100;", "0"
)
limbo.run_test("update-limit-zero-result", "SELECT COUNT(*) from t WHERE a = 100;", "0")
limbo.run_test("update-limit-all", "UPDATE t SET a = 100 LIMIT -1;", "")
# negative limit is treated as no limit in sqlite due to check for --val = 0
limbo.run_test("update-limit-result", "SELECT COUNT(*) from t WHERE a = 100;", "6")
limbo.run_test(
"udpate-limit-where", "UPDATE t SET a = 333 WHERE b = 5 LIMIT 1;", ""
)
limbo.run_test(
"update-limit-where-result", "SELECT COUNT(*) from t WHERE a = 333;", "1"
)
limbo.run_test("udpate-limit-where", "UPDATE t SET a = 333 WHERE b = 5 LIMIT 1;", "")
limbo.run_test("update-limit-where-result", "SELECT COUNT(*) from t WHERE a = 333;", "1")
limbo.quit()
def test_update_with_limit_and_offset():
limbo = TestLimboShell(
"CREATE TABLE t (a,b,c); insert into t values (1,2,3), (4,5,6), (7,8,9), (1,2,3),(4,5,6), (7,8,9);"
)
limbo.run_test("update-limit-offset", "UPDATE t SET a = 10 LIMIT 1 OFFSET 3;", "")
limbo.run_test(
"update-limit-offset-result", "SELECT COUNT(*) from t WHERE a = 10;", "1"
)
limbo.run_test("update-limit-offset-result", "SELECT COUNT(*) from t WHERE a = 10;", "1")
limbo.run_test("update-limit-result", "SELECT a from t LIMIT 4;", "1\n4\n7\n10")
limbo.run_test(
"update-limit-offset-zero", "UPDATE t SET a = 100 LIMIT 0 OFFSET 0;", ""
)
limbo.run_test(
"update-limit-zero-result", "SELECT COUNT(*) from t WHERE a = 100;", "0"
)
limbo.run_test("update-limit-offset-zero", "UPDATE t SET a = 100 LIMIT 0 OFFSET 0;", "")
limbo.run_test("update-limit-zero-result", "SELECT COUNT(*) from t WHERE a = 100;", "0")
limbo.run_test("update-limit-all", "UPDATE t SET a = 100 LIMIT -1 OFFSET 1;", "")
limbo.run_test("update-limit-result", "SELECT COUNT(*) from t WHERE a = 100;", "5")
limbo.run_test(
"udpate-limit-where", "UPDATE t SET a = 333 WHERE b = 5 LIMIT 1 OFFSET 2;", ""
)
limbo.run_test(
"update-limit-where-result", "SELECT COUNT(*) from t WHERE a = 333;", "0"
)
limbo.run_test("udpate-limit-where", "UPDATE t SET a = 333 WHERE b = 5 LIMIT 1 OFFSET 2;", "")
limbo.run_test("update-limit-where-result", "SELECT COUNT(*) from t WHERE a = 333;", "0")
limbo.quit()
def test_insert_default_values():
limbo = TestLimboShell(
"CREATE TABLE t (a integer default(42),b integer default (43),c integer default(44));"
)
limbo = TestLimboShell("CREATE TABLE t (a integer default(42),b integer default (43),c integer default(44));")
for _ in range(1, 10):
limbo.execute_dot("INSERT INTO t DEFAULT VALUES;")
limbo.run_test("insert-default-values", "SELECT * FROM t;", "42|43|44\n" * 9)

View file

@ -1,9 +1,9 @@
#!/usr/bin/env python3
import os
from cli_tests import console
from cli_tests.test_limbo_cli import TestLimboShell
from pydantic import BaseModel
from cli_tests import console
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")
@ -81,13 +81,13 @@ class CollateTest(BaseModel):
)
limbo.run_test(
"Grouping is performed using the NOCASE collating sequence (Values 'abc', 'ABC', and 'Abc' are placed in the same group).",
"Grouping is performed using the NOCASE collating sequence (Values 'abc', 'ABC', and 'Abc' are placed in the same group).", # noqa: E501
"SELECT count(*) FROM t1 GROUP BY d ORDER BY 1;",
"\n".join(map(lambda x: str(x), [4])),
)
limbo.run_test(
"Grouping is performed using the BINARY collating sequence. 'abc' and 'ABC' and 'Abc' form different groups",
"Grouping is performed using the BINARY collating sequence. 'abc' and 'ABC' and 'Abc' form different groups", # noqa: E501
"SELECT count(*) FROM t1 GROUP BY (d || '') ORDER BY 1;",
"\n".join(map(lambda x: str(x), [1, 1, 2])),
)

View file

@ -1,8 +1,8 @@
from typing import Any, Optional, Union
from rich.console import Console, JustifyMethod
from rich.theme import Theme
from rich.style import Style
from rich.console import Console, JustifyMethod
from rich.style import Style
from rich.theme import Theme
custom_theme = Theme(
{
@ -95,6 +95,7 @@ def debug(
_stack_offset=_stack_offset + 1,
)
def test(
*objects: Any,
sep: str = " ",
@ -119,4 +120,4 @@ def test(
highlight=highlight,
log_locals=log_locals,
_stack_offset=_stack_offset + 1,
)
)

View file

@ -2,15 +2,16 @@
# Eventually extract these tests to be in the fuzzing integration tests
import os
import tempfile
from faker import Faker
from faker.providers.lorem.en_US import Provider as P
from cli_tests.test_limbo_cli import TestLimboShell
from pydantic import BaseModel
from cli_tests import console
from enum import Enum
import random
import sqlite3
import tempfile
from enum import Enum
from cli_tests import console
from cli_tests.test_limbo_cli import TestLimboShell
from faker import Faker
from faker.providers.lorem.en_US import Provider as P
from pydantic import BaseModel
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")
@ -233,11 +234,7 @@ class Table(BaseModel):
# These statements should always cause a constraint error as there is no where clause here
def generate_update(self) -> str:
vals = [
f"{col.name} = {col.col_type.generate(fake)}"
for col in self.columns
if col.primary_key
]
vals = [f"{col.name} = {col.col_type.generate(fake)}" for col in self.columns if col.primary_key]
vals = ", ".join(vals)
return f"UPDATE {self.name} SET {vals};"
@ -374,7 +371,7 @@ def main():
tests = all_tests()
for test in tests:
console.info(test.table)
with tempfile.NamedTemporaryFile(suffix='.db') as tmp:
with tempfile.NamedTemporaryFile(suffix=".db") as tmp:
try:
# Use with syntax to automatically close shell on error
with TestLimboShell("") as limbo:
@ -387,7 +384,7 @@ def main():
tests = [custom_test_2, regression_test_update_single_key]
for test in tests:
with tempfile.NamedTemporaryFile(suffix='.db') as tmp:
with tempfile.NamedTemporaryFile(suffix=".db") as tmp:
try:
with TestLimboShell("") as limbo:
limbo.execute_dot(f".open {tmp.name}")

View file

@ -1,7 +1,8 @@
#!/usr/bin/env python3
import os
from cli_tests.test_limbo_cli import TestLimboShell
from cli_tests import console
from cli_tests.test_limbo_cli import TestLimboShell
sqlite_exec = "./scripts/limbo-sqlite3"
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")
@ -40,14 +41,10 @@ def test_uuid():
)
limbo.run_test_fn("SELECT uuid4_str();", lambda res: len(res) == 36)
limbo.run_test_fn("SELECT hex(uuid7());", lambda res: int(res, 16) is not None)
limbo.run_test_fn(
"SELECT uuid7_timestamp_ms(uuid7()) / 1000;", lambda res: res.isdigit()
)
limbo.run_test_fn("SELECT uuid7_timestamp_ms(uuid7()) / 1000;", lambda res: res.isdigit())
limbo.run_test_fn("SELECT uuid7_str();", validate_string_uuid)
limbo.run_test_fn("SELECT uuid_str(uuid7());", validate_string_uuid)
limbo.run_test_fn(
"SELECT hex(uuid_blob(uuid7_str()));", lambda res: int(res, 16) is not None
)
limbo.run_test_fn("SELECT hex(uuid_blob(uuid7_str()));", lambda res: int(res, 16) is not None)
limbo.run_test_fn("SELECT uuid_str(uuid_blob(uuid7_str()));", validate_string_uuid)
limbo.run_test_fn(
f"SELECT uuid7_timestamp_ms('{specific_time}') / 1000;",
@ -160,12 +157,8 @@ def test_aggregates():
validate_percentile2,
"test aggregate percentile function with 1 argument works",
)
limbo.run_test_fn(
"SELECT percentile_cont(value, 0.25) from test;", validate_percentile1
)
limbo.run_test_fn(
"SELECT percentile_disc(value, 0.55) from test;", validate_percentile_disc
)
limbo.run_test_fn("SELECT percentile_cont(value, 0.25) from test;", validate_percentile1)
limbo.run_test_fn("SELECT percentile_disc(value, 0.55) from test;", validate_percentile_disc)
limbo.quit()
@ -223,8 +216,7 @@ def test_crypto():
# Hashing and Decode
limbo.run_test_fn(
"SELECT crypto_encode(crypto_blake3('abc'), 'hex');",
lambda res: res
== "6437b3ac38465133ffb63b75273a8db548c558465d79db03fd359c6cd5bd9d85",
lambda res: res == "6437b3ac38465133ffb63b75273a8db548c558465d79db03fd359c6cd5bd9d85",
"blake3 should encrypt correctly",
)
limbo.run_test_fn(
@ -239,8 +231,7 @@ def test_crypto():
)
limbo.run_test_fn(
"SELECT crypto_encode(crypto_sha256('abc'), 'hex');",
lambda a: a
== "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
lambda a: a == "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
"sha256 should encrypt correctly",
)
limbo.run_test_fn(
@ -252,7 +243,7 @@ def test_crypto():
limbo.run_test_fn(
"SELECT crypto_encode(crypto_sha512('abc'), 'hex');",
lambda a: a
== "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",
== "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", # noqa: E501
"sha512 should encrypt correctly",
)
@ -401,9 +392,7 @@ def test_kv():
)
for i in range(100):
limbo.execute_dot(f"insert into t values ('key{i}', 'val{i}');")
limbo.run_test_fn(
"select count(*) from t;", lambda res: "100" == res, "can insert 100 rows"
)
limbo.run_test_fn("select count(*) from t;", lambda res: "100" == res, "can insert 100 rows")
limbo.run_test_fn("update t set value = 'updated' where key = 'key33';", null)
limbo.run_test_fn(
"select * from t where key = 'key33';",
@ -422,12 +411,8 @@ def test_kv():
"can update all rows",
)
limbo.run_test_fn("delete from t limit 96;", null, "can delete 96 rows")
limbo.run_test_fn(
"select count(*) from t;", lambda res: "4" == res, "four rows remain"
)
limbo.run_test_fn(
"update t set key = '100' where 1;", null, "where clause evaluates properly"
)
limbo.run_test_fn("select count(*) from t;", lambda res: "4" == res, "four rows remain")
limbo.run_test_fn("update t set key = '100' where 1;", null, "where clause evaluates properly")
limbo.run_test_fn(
"select * from t where key = '100';",
lambda res: res == "100|updated2",
@ -509,9 +494,7 @@ def test_vfs():
ext_path = "target/debug/liblimbo_ext_tests"
limbo.run_test_fn(".vfslist", lambda x: "testvfs" not in x, "testvfs not loaded")
limbo.execute_dot(f".load {ext_path}")
limbo.run_test_fn(
".vfslist", lambda res: "testvfs" in res, "testvfs extension loaded"
)
limbo.run_test_fn(".vfslist", lambda res: "testvfs" in res, "testvfs extension loaded")
limbo.execute_dot(".open testing/vfs.db testvfs")
limbo.execute_dot("create table test (id integer primary key, value float);")
limbo.execute_dot("create table vfs (id integer primary key, value blob);")
@ -742,8 +725,7 @@ def test_tablestats():
limbo.run_test_fn(
"SELECT * FROM stats ORDER BY name;",
lambda res: sorted(_split(res))
== sorted(["logs|1", "people|3", "products|11", "users|10000"]),
lambda res: sorted(_split(res)) == sorted(["logs|1", "people|3", "products|11", "users|10000"]),
"stats shows correct initial counts (and skips itself)",
)

View file

@ -1,7 +1,8 @@
#!/usr/bin/env python3
import os
from cli_tests.test_limbo_cli import TestLimboShell
from cli_tests import console
from cli_tests.test_limbo_cli import TestLimboShell
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")

View file

@ -1,12 +1,12 @@
#!/usr/bin/env python3
import os
import select
from time import sleep
import subprocess
from pathlib import Path
from time import sleep
from typing import Callable, List, Optional
from cli_tests import console
from cli_tests import console
PIPE_BUF = 4096
@ -107,7 +107,7 @@ class TestLimboShell:
flags="",
):
if exec_name is None:
exec_name = os.environ.get('SQLITE_EXEC')
exec_name = os.environ.get("SQLITE_EXEC")
if exec_name is None:
exec_name = "./scripts/limbo-sqlite3"
if flags == "":
@ -142,10 +142,7 @@ INSERT INTO t VALUES (zeroblob(1024 - 1), zeroblob(1024 - 2), zeroblob(1024 - 3)
console.test(f"Running test: {name}", _stack_offset=2)
actual = self.shell.execute(sql)
assert actual == expected, (
f"Test failed: {name}\n"
f"SQL: {sql}\n"
f"Expected:\n{repr(expected)}\n"
f"Actual:\n{repr(actual)}"
f"Test failed: {name}\nSQL: {sql}\nExpected:\n{repr(expected)}\nActual:\n{repr(actual)}"
)
def run_debug(self, sql: str):
@ -153,9 +150,7 @@ INSERT INTO t VALUES (zeroblob(1024 - 1), zeroblob(1024 - 2), zeroblob(1024 - 3)
actual = self.shell.execute(sql)
console.debug(f"OUTPUT:\n{repr(actual)}", _stack_offset=2)
def run_test_fn(
self, sql: str, validate: Callable[[str], bool], desc: str = ""
) -> None:
def run_test_fn(self, sql: str, validate: Callable[[str], bool], desc: str = "") -> None:
# Print the test that is executing before executing the sql command
# Printing later confuses the user of the code what test has actually failed
if desc:

View file

@ -1,9 +1,9 @@
#!/usr/bin/env python3
import os
from cli_tests import console
from cli_tests.test_limbo_cli import TestLimboShell
from pydantic import BaseModel
from cli_tests import console
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")
@ -39,10 +39,7 @@ class UpdateTest(BaseModel):
f"{self.vals}",
)
stmt = [
f"SELECT hex(t1), t2, t3 FROM test LIMIT 1 OFFSET {i};"
for i in range(self.vals)
]
stmt = [f"SELECT hex(t1), t2, t3 FROM test LIMIT 1 OFFSET {i};" for i in range(self.vals)]
expected = [f"{zero_blob}|{t2_val}|{t3_val}" for _ in range(self.vals)]
sqlite.run_test(
@ -84,15 +81,10 @@ class UpdateTest(BaseModel):
f"{self.vals}",
)
stmt = [
f"SELECT hex(t1), t2, t3 FROM test LIMIT 1 OFFSET {i};"
for i in range(self.vals)
]
stmt = [f"SELECT hex(t1), t2, t3 FROM test LIMIT 1 OFFSET {i};" for i in range(self.vals)]
expected = [
f"{zero_blob}|{t2_val}|{t3_val}"
if i != 0
else f"{zero_blob}|{t2_update_val}|{t3_val}"
f"{zero_blob}|{t2_val}|{t3_val}" if i != 0 else f"{zero_blob}|{t2_update_val}|{t3_val}"
for i in range(self.vals)
]
sqlite.run_test(

View file

@ -1,16 +1,16 @@
#!/usr/bin/env python3
# vfs benchmarking/comparison
import os
from pathlib import Path
import subprocess
import statistics
import argparse
import os
import statistics
import subprocess
from pathlib import Path
from time import perf_counter, sleep
from typing import Dict
from cli_tests.console import error, info, test
from cli_tests.test_limbo_cli import TestLimboShell
from cli_tests.console import info, error, test
LIMBO_BIN = Path("./target/release/limbo")
DB_FILE = Path("testing/temp.db")
@ -37,9 +37,7 @@ def bench_one(vfs: str, sql: str, iterations: int) -> list[float]:
for i in range(1, iterations + 1):
start = perf_counter()
_ = shell.run_test_fn(
sql, lambda x: x is not None and append_time(times, start, perf_counter)
)
_ = shell.run_test_fn(sql, lambda x: x is not None and append_time(times, start, perf_counter))
test(f" {vfs} | run {i:>3}: {times[-1]:.6f}s")
shell.quit()
@ -60,9 +58,7 @@ def cleanup_temp_db() -> None:
def main() -> None:
parser = argparse.ArgumentParser(
description="Benchmark a SQL statement against all Limbo VFS backends."
)
parser = argparse.ArgumentParser(description="Benchmark a SQL statement against all Limbo VFS backends.")
parser.add_argument("sql", help="SQL statement to execute (quote it)")
parser.add_argument("iterations", type=int, help="number of repetitions")
args = parser.parse_args()
@ -105,9 +101,7 @@ def main() -> None:
else:
pct = (avg - baseline_avg) / baseline_avg * 100.0
faster_slower = "slower" if pct > 0 else "faster"
info(
f"{vfs:<{name_pad}} : {avg:.6f} ({abs(pct):.1f}% {faster_slower} than {baseline})"
)
info(f"{vfs:<{name_pad}} : {avg:.6f} ({abs(pct):.1f}% {faster_slower} than {baseline})")
info("-" * 60)
cleanup_temp_db()

View file

@ -1,11 +1,11 @@
#!/usr/bin/env python3
import os
import tempfile
from cli_tests.test_limbo_cli import TestLimboShell
from pydantic import BaseModel
from cli_tests import console
from time import sleep
from cli_tests import console
from cli_tests.test_limbo_cli import TestLimboShell
from pydantic import BaseModel
sqlite_flags = os.getenv("SQLITE_FLAGS", "-q").split(" ")
@ -46,9 +46,7 @@ class InsertTest(BaseModel):
big_stmt = "".join(big_stmt)
expected = "\n".join(expected)
limbo.run_test_fn(
big_stmt, lambda res: validate_with_expected(res, expected), self.name
)
limbo.run_test_fn(big_stmt, lambda res: validate_with_expected(res, expected), self.name)
def test_compat(self):
console.info("Testing in SQLite\n")

View file

@ -1,13 +1,14 @@
#!/usr/bin/env python3
import sqlite3
from faker import Faker
conn = sqlite3.connect('database.db')
conn = sqlite3.connect("database.db")
cursor = conn.cursor()
# Create the user table
cursor.execute('''
cursor.execute("""
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY,
first_name TEXT,
@ -20,18 +21,29 @@ cursor.execute('''
zipcode TEXT,
age INTEGER
)
''')
""")
cursor.execute('''
cursor.execute("""
CREATE TABLE IF NOT EXISTS products (
id INTEGER PRIMARY KEY,
name TEXT,
price REAL
)
''')
""")
product_list = ["hat", "cap", "shirt", "sweater", "sweatshirt",
"shorts", "jeans", "sneakers", "boots", "coat", "accessories"]
product_list = [
"hat",
"cap",
"shirt",
"sweater",
"sweatshirt",
"shorts",
"jeans",
"sneakers",
"boots",
"coat",
"accessories",
]
fake = Faker()
for _ in range(10000):
@ -45,18 +57,23 @@ for _ in range(10000):
zipcode = fake.zipcode()
age = fake.random_int(min=1, max=100)
cursor.execute('''
cursor.execute(
"""
INSERT INTO users (first_name, last_name, email, phone_number, address, city, state, zipcode, age)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (first_name, last_name, email, phone_number, address, city, state, zipcode, age))
""",
(first_name, last_name, email, phone_number, address, city, state, zipcode, age),
)
for product in product_list:
price = fake.random_int(min=1, max=100)
cursor.execute('''
cursor.execute(
"""
INSERT INTO products (name, price)
VALUES (?, ?)
''', (product, price))
""",
(product, price),
)
conn.commit()