You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-8Lines changed: 44 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,20 @@
1
1
# SQLite Query Manager
2
2
3
-
`sqlite_query_manager` is a Python package designed to efficiently manage and
3
+
`sqlite_manager` is a Python package designed to efficiently manage and
4
4
execute SQL queries on SQLite databases. The package supports organizing SQL queries in directories, running them sequentially or selectively, and exporting the results as CSV files. It also includes flexible options to rerun all queries, specific queries, or skip those with existing outputs.
5
5
6
6
## Table of Contents
7
7
8
8
-[Introduction](#introduction)
9
9
-[Usage](#usage)
10
-
-[Basic Example](#basic-example)
11
10
-[Directory Layouts](#directory-layouts)
12
11
-[Installation](#installation)
13
12
14
13
---
15
14
16
15
## Introduction
17
16
18
-
The `sqlite_query_manager` package simplifies SQL query execution workflows by:
17
+
The `sqlite_manager` package simplifies SQL query execution workflows by:
19
18
- Recursively processing SQL queries from directories.
20
19
- Mirroring directory structures for outputs.
21
20
- Avoiding redundant execution of queries unless explicitly specified.
@@ -27,12 +26,49 @@ This makes it ideal for projects involving multiple interdependent queries, such
27
26
28
27
## Usage
29
28
30
-
### Basic Example
29
+
### `create_sqlite_db` function:
31
30
32
-
Here’s a minimal example of how to use the `run_sql_queries` function:
31
+
```python
32
+
# Import necessary modules
33
+
import pandas as pd
34
+
from sqlite_manager import create_sqlite_db
35
+
36
+
# Example DataFrame
37
+
data = {
38
+
"id": [1, 2, 3],
39
+
"name": ["Alice", "Bob", "Charlie"],
40
+
"age": [25, 30, 35]
41
+
}
42
+
df = pd.DataFrame(data)
43
+
44
+
# Path to schema file (must contain the table definition)
45
+
schema_file ="db_schema.sql"
46
+
47
+
# Example schema (contents of db_schema.sql)
48
+
# CREATE TABLE ExampleTable (
49
+
# id INTEGER PRIMARY KEY,
50
+
# name TEXT,
51
+
# age INTEGER
52
+
# );
53
+
54
+
# Path to SQLite database file
55
+
db_file ="example_database.db"
56
+
57
+
# Create SQLite database from the DataFrame
58
+
create_sqlite_db(
59
+
df,
60
+
schema_file,
61
+
db_file
62
+
)
63
+
64
+
# Verify: The database is created, and data is inserted into the ExampleTable.
65
+
print(f"Database '{db_file}' created successfully with data from the DataFrame.")
0 commit comments