-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix r-string issues with variables + sort improvement (#84) + ODBC In…
…put (#14)
- Loading branch information
Showing
23 changed files
with
329 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# This file is auto-generated by Hatchling. As such, do not: | ||
# - modify | ||
# - track in version control e.g. be sure to add to .gitignore | ||
__version__ = VERSION = '0.5.95' | ||
__version__ = VERSION = '0.5.97' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"npmClient": "yarn", | ||
"version": "0.5.95" | ||
"version": "0.5.97" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@amphi/amphi-etl", | ||
"version": "0.5.95", | ||
"version": "0.5.97", | ||
"keywords": [ | ||
"amphi", | ||
"etl", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
jupyterlab==4.2.5 | ||
jupyterlab-amphi==0.5.95 | ||
jupyterlab-amphi==0.5.97 | ||
pandas==2.2.1 | ||
# ../jupyterlab-amphi | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
"""source of truth for ``amphi``` version.""" | ||
__version__ = "0.5.95" | ||
__version__ = "0.5.97" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"npmClient": "yarn", | ||
"version": "0.5.95" | ||
"version": "0.5.97" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@amphi/jupyterlab-amphi", | ||
"version": "0.5.95", | ||
"version": "0.5.97", | ||
"keywords": [ | ||
"amphi", | ||
"etl", | ||
|
2 changes: 1 addition & 1 deletion
2
jupyterlab-amphi/packages/pipeline-components-core/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...lab-amphi/packages/pipeline-components-core/src/components/inputs/databases/ODBCInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { databaseIcon } from '../../../icons'; | ||
import { BaseCoreComponent } from '../../BaseCoreComponent'; | ||
|
||
export class ODBCInput extends BaseCoreComponent { | ||
constructor() { | ||
const defaultConfig = { | ||
connectionString: "", | ||
queryMethod: "table", | ||
tableName: "", | ||
sqlQuery: "", | ||
autoCommit: true | ||
}; | ||
const form = { | ||
fields: [ | ||
{ | ||
type: "input", | ||
label: "Connection String", | ||
id: "connectionString", | ||
placeholder: "Enter ODBC connection string", | ||
tooltip: "Provide the full ODBC connection string for your database. Reference: https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-databases", | ||
connection: "ODBC", | ||
advanced: true | ||
}, | ||
{ | ||
type: "boolean", | ||
label: "Auto Commit", | ||
tooltip: "Setting autocommit True will cause the database to issue a commit after each SQL statement, otherwise database transactions will have to be explicity committed. As per the Python DB API, the default value is False (even though the ODBC default value is True). Typically, you will probably want to set autocommit True when creating a connection.", | ||
id: "autoCommit", | ||
advanced: true | ||
}, | ||
{ | ||
type: "radio", | ||
label: "Query Method", | ||
id: "queryMethod", | ||
tooltip: "Select whether you want to specify the table name to retrieve data or use a custom SQL query for greater flexibility.", | ||
options: [ | ||
{ value: "table", label: "Table Name" }, | ||
{ value: "query", label: "SQL Query" } | ||
], | ||
advanced: true | ||
}, | ||
{ | ||
type: "input", | ||
label: "Table Name", | ||
id: "tableName", | ||
placeholder: "Enter table name", | ||
condition: { queryMethod: "table" } | ||
}, | ||
{ | ||
type: "codeTextarea", | ||
label: "SQL Query", | ||
height: '50px', | ||
mode: "sql", | ||
placeholder: 'SELECT * FROM table_name', | ||
id: "sqlQuery", | ||
tooltip: 'Optional. By default the SQL query is: SELECT * FROM table_name_provided. If specified, the SQL Query is used.', | ||
condition: { queryMethod: "query" }, | ||
advanced: true | ||
} | ||
], | ||
}; | ||
const description = "Use ODBC Input to retrieve data from various databases using an ODBC connection string, along with either a table name or a custom SQL query." | ||
|
||
super("ODBC Input", "odbcInput", description, "pandas_df_input", [], "inputs.Databases", databaseIcon, defaultConfig, form); | ||
} | ||
|
||
public provideDependencies({ config }): string[] { | ||
return ['pyodbc']; | ||
} | ||
|
||
public provideImports({ config }): string[] { | ||
return ["import pandas as pd", "import pyodbc"]; | ||
} | ||
|
||
public generateComponentCode({ config, outputName }): string { | ||
// Escape single quotes in the connection string | ||
const connectionString = config.connectionString.replace(/'/g, "\\'"); | ||
const autoCommit = config.autoCommit; | ||
|
||
const sqlQuery = config.queryMethod === 'query' && config.sqlQuery && config.sqlQuery.trim() | ||
? config.sqlQuery | ||
: `SELECT * FROM ${config.tableName}`; | ||
|
||
const code = ` | ||
# Connect to the database using ODBC | ||
conn = pyodbc.connect(f"""${connectionString}""", autocommit=${autoCommit ? 'True' : 'False'}) | ||
# Execute SQL statement | ||
try: | ||
${outputName} = pd.read_sql( | ||
"""${sqlQuery}""", | ||
conn | ||
).convert_dtypes() | ||
finally: | ||
conn.close() | ||
`; | ||
return code; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
jupyterlab-amphi/packages/pipeline-components-core/style/icons/database-24.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
jupyterlab-amphi/packages/pipeline-components-manager/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.