analitics

Pages

Showing posts with label DuckDB. Show all posts
Showing posts with label DuckDB. Show all posts

Tuesday, September 17, 2024

Python 3.12.3 : PyGame, DuckDB and AgentPy on Fedora 42 linux distro.

Today I tested the installation of some python packages in the Fedora 42 Linux distribution. On the Windows 10 operating system I failed to install pygame because it was trying to build.

[mythcat@fedora ~]$ pip install duckdb --upgrade
Defaulting to user installation because normal site-packages is not writeable
Collecting duckdb
...
Installing collected packages: duckdb
Successfully installed duckdb-1.1.0
[mythcat@fedora ~]$ pip install pygame
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pygame in ./.local/lib/python3.12/site-packages (2.5.2)
[mythcat@fedora ~]$ pip install agentpy
...
Installing collected packages: scipy, networkx, kiwisolver, joblib, fonttools, dill, cycler, contourpy, pandas, multiprocess, matplotlib, SALib, agentpy
Successfully installed SALib-1.5.1 agentpy-0.1.5 contourpy-1.3.0 cycler-0.12.1 dill-0.3.8 fonttools-4.53.1 joblib-1.4.2 kiwisolver-1.4.7 matplotlib-3.9.2 multiprocess-0.70.16 networkx-3.3 pandas-2.2.2 scipy-1.14.1

Friday, September 6, 2024

Python 3.12.4 : DuckDB operate in in-memory mode.

DuckDB aims to automatically achieve high performance by using well-chosen default configurations and having a forgiving architecture. Of course, there are still opportunities for tuning the system for specific workloads. The Performance Guide's page contain guidelines and tips for achieving good performance when loading and processing data with DuckDB.
DuckDB can operate in in-memory mode. In most clients, this can be activated by passing the special value :memory: as the database file or omitting the database file argument.
You can use with python or another programming language.
I used Python 3.13.0rc1 version and pip tool ...
pip install duckdb --upgrade
Collecting duckdb
...
Installing collected packages: duckdb
Successfully installed duckdb-1.0.0
I created a python script :
python test_memory_duckdb_sqlite_db.py
[]
[('table', 'users', 'users', 0, 'CREATE TABLE users(id BIGINT PRIMARY KEY, first_name VARCHAR, last_name VARCHAR, occupation VARCHAR, hobby VARCHAR, year_of_birth BIGINT, age BIGINT);')]
This is the source code I used:
import duckdb

# Conectare la baza de date în memorie
con = duckdb.connect(database=':memory:')

# Instalează extensia sqlite
con.execute("INSTALL sqlite")

# Încarcă extensia sqlite
con.execute("LOAD sqlite")

# Verifică dacă extensia este încărcată
result = con.execute("SELECT * FROM sqlite_master").fetchall()
print(result)

# Conectare la baza de date pe disc
con_disk = duckdb.connect(database='sqlite_database.db', read_only=False)

# Instalează extensia sqlite pentru baza de date pe disc
con_disk.execute("INSTALL sqlite")

# Încarcă extensia sqlite pentru baza de date pe disc
con_disk.execute("LOAD sqlite")

# Verifică dacă extensia este încărcată pentru baza de date pe disc
result_disk = con_disk.execute("SELECT * FROM sqlite_master").fetchall()
print(result_disk)