# Convert any SQL Database to a Pandas DataFrame
```python
$ pip install a-pandas-ex-read-sql
from a_pandas_ex_read_sql import pd_add_read_sql_file
pd_add_read_sql_file()
import pandas as pd
dict_with_dfs = pd.Q_read_sql(r"F:\msgstorexxxxxxxxxxxxxxxxx.db")
```
### Update 13.5:
```python
# Added .SQL File Reading Functionality
# To read an .SQL file and obtain the data, you can use the pd.Q_read_sql() function.
# This code reads the specified SQL file (.sql - only INSERT commands) and returns a DataFrame containing the data from the file.
df = pd.Q_read_sql(r"C:\Users\hansc\Downloads\sax\world.sql")
# Reading an SQLite Database File (.db)
# To read an SQLite database file and retrieve the data, you can also use the pd.Q_read_sql() function.
# This code reads the specified SQLite database file (northwind.db) and returns a DataFrame containing the data in a dict of DataFrames.
df2 = pd.Q_read_sql(r"C:\Users\hansc\Downloads\northwind.db")
# To convert all tables in an SQLite database file into a single DataFrame, you can use the pd.Q_db_to_one_df() # function. This code reads the specified SQLite database file (northwind.db), retrieves all the tables, and combines them into a single DataFrame.
df3 = pd.Q_db_to_one_df(path=r"C:\Users\hansc\Downloads\northwind.db")
# Splitting a DataFrame into Grouped DataFrames (Revert the last step)
# To split a DataFrame into multiple DataFrames based on specified columns, you can use the d_split_in_groups() # function. This code splits the DataFrame (df3) into multiple DataFrames based on the "aa_table" column. The result is a dictionary where the keys are group names, and the values are the corresponding split DataFrames.
df4 = df3.d_split_in_groups(columns=["aa_table"])
# To revert the grouped DataFrames back into a single DataFrame (without reading SQL), you can use the pd.Q_groupdict_to_one_df() function.
# This code takes the dictionary of grouped DataFrames (df4) and combines them into a single DataFrame.
df5 = pd.Q_groupdict_to_one_df(df4)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/a_pandas_ex_read_sql",
"name": "a-pandas-ex-read-sql",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "sql,pandas,SQLite,mysql,DataFrame",
"author": "Johannes Fischer",
"author_email": "aulasparticularesdealemaosp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/20/e5/1184505e7a714b3642e5fe0783afeef0f6f1868fe6b79e7a59e25457b636/a_pandas_ex_read_sql-0.11.tar.gz",
"platform": null,
"description": "# Convert any SQL Database to a Pandas DataFrame\r\n\r\n\r\n```python\r\n$ pip install a-pandas-ex-read-sql\r\nfrom a_pandas_ex_read_sql import pd_add_read_sql_file\r\npd_add_read_sql_file()\r\nimport pandas as pd\r\ndict_with_dfs = pd.Q_read_sql(r\"F:\\msgstorexxxxxxxxxxxxxxxxx.db\")\r\n```\r\n\r\n\r\n\r\n\r\n\r\n\r\n### Update 13.5: \r\n\r\n```python\r\n# Added .SQL File Reading Functionality\r\n# To read an .SQL file and obtain the data, you can use the pd.Q_read_sql() function.\r\n# This code reads the specified SQL file (.sql - only INSERT commands) and returns a DataFrame containing the data from the file.\r\ndf = pd.Q_read_sql(r\"C:\\Users\\hansc\\Downloads\\sax\\world.sql\")\r\n\r\n# Reading an SQLite Database File (.db)\r\n# To read an SQLite database file and retrieve the data, you can also use the pd.Q_read_sql() function.\r\n# This code reads the specified SQLite database file (northwind.db) and returns a DataFrame containing the data in a dict of DataFrames.\r\n\r\ndf2 = pd.Q_read_sql(r\"C:\\Users\\hansc\\Downloads\\northwind.db\")\r\n\r\n\r\n# To convert all tables in an SQLite database file into a single DataFrame, you can use the pd.Q_db_to_one_df() # function. This code reads the specified SQLite database file (northwind.db), retrieves all the tables, and combines them into a single DataFrame.\r\ndf3 = pd.Q_db_to_one_df(path=r\"C:\\Users\\hansc\\Downloads\\northwind.db\")\r\n\r\n\r\n\r\n# Splitting a DataFrame into Grouped DataFrames (Revert the last step)\r\n# To split a DataFrame into multiple DataFrames based on specified columns, you can use the d_split_in_groups() # function. This code splits the DataFrame (df3) into multiple DataFrames based on the \"aa_table\" column. The result is a dictionary where the keys are group names, and the values are the corresponding split DataFrames.\r\n\r\ndf4 = df3.d_split_in_groups(columns=[\"aa_table\"])\r\n\r\n# To revert the grouped DataFrames back into a single DataFrame (without reading SQL), you can use the pd.Q_groupdict_to_one_df() function. \r\n# This code takes the dictionary of grouped DataFrames (df4) and combines them into a single DataFrame.\r\ndf5 = pd.Q_groupdict_to_one_df(df4)\r\n\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Convert any SQL Database to a Pandas DataFrame",
"version": "0.11",
"project_urls": {
"Homepage": "https://github.com/hansalemaos/a_pandas_ex_read_sql"
},
"split_keywords": [
"sql",
"pandas",
"sqlite",
"mysql",
"dataframe"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "78e23eaf709934feec31188f73bb684648f31314569e2376fd351fd62d0a83b8",
"md5": "04d5c3b9ecca58f130fdb7df15b802bb",
"sha256": "3988d4f68fa13258fecb2d0cac3834f2e6cb12838074a27a399ea698520bbeb0"
},
"downloads": -1,
"filename": "a_pandas_ex_read_sql-0.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "04d5c3b9ecca58f130fdb7df15b802bb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8128,
"upload_time": "2023-05-13T18:15:35",
"upload_time_iso_8601": "2023-05-13T18:15:35.437163Z",
"url": "https://files.pythonhosted.org/packages/78/e2/3eaf709934feec31188f73bb684648f31314569e2376fd351fd62d0a83b8/a_pandas_ex_read_sql-0.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "20e51184505e7a714b3642e5fe0783afeef0f6f1868fe6b79e7a59e25457b636",
"md5": "17fd2a707da9132988624349bed10a77",
"sha256": "233f2e0a7df947135cd4a1e01e0f62034cf3246ae4d646910915a31de27fa58e"
},
"downloads": -1,
"filename": "a_pandas_ex_read_sql-0.11.tar.gz",
"has_sig": false,
"md5_digest": "17fd2a707da9132988624349bed10a77",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6435,
"upload_time": "2023-05-13T18:15:37",
"upload_time_iso_8601": "2023-05-13T18:15:37.497835Z",
"url": "https://files.pythonhosted.org/packages/20/e5/1184505e7a714b3642e5fe0783afeef0f6f1868fe6b79e7a59e25457b636/a_pandas_ex_read_sql-0.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-13 18:15:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hansalemaos",
"github_project": "a_pandas_ex_read_sql",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "a_pandas_ex_apply_ignore_exceptions",
"specs": []
},
{
"name": "a_pandas_ex_less_memory_more_speed",
"specs": []
},
{
"name": "check_if_nan",
"specs": []
},
{
"name": "pandas",
"specs": []
},
{
"name": "sqlparse",
"specs": []
}
],
"lcname": "a-pandas-ex-read-sql"
}