'sqlalchemy cannot create URL object 'NameError: name 'URL' is not defined'
A couple weeks ago I was able to create a connection to SQL server using the following lines.
import sqlalchemy
connection_string = 'Driver={SQL Server};' 'Server=someserver;' 'Database=some_db;' 'Trusted_Connection=yes;'
connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": connection_string})
engine = create_engine(connection_url)
Today I went to run it again and I got the following error
NameError Traceback (most recent call last)
Input In [8], in <cell line: 3>()
1 import sqlalchemy
2 connection_string = 'Driver={SQL Server};' 'Server=someserver;' 'Database=some_db;' 'Trusted_Connection=yes;'
----> 3 connection_url = URL.create("mssql+pyodbc", query={"odbc_connect": connection_string})
5 engine = create_engine(connection_url)
NameError: name 'URL' is not defined
I created a new env and reinstalled all of the packages I was using. That did not help. Can anyone help me understand why I can't create the URL object? I tried using make_url and got a separate error below
AttributeError Traceback (most recent call last)
Input In [9], in <cell line: 3>()
1 import sqlalchemy
2 connection_string = 'Driver={SQL Server};' 'Server=someserver;' 'Database=some_db;' 'Trusted_Connection=yes;'
----> 3 connection_url = sqlalchemy.make_url("mssql+pyodbc", query={"odbc_connect": connection_string})
5 engine = create_engine(connection_url)
AttributeError: module 'sqlalchemy' has no attribute 'make_url'
Does anyone see what I am doing wrong? I'm perplexed because this worked fine the last time I ran this.
Solution 1:[1]
Wellcome WisarootK! I guess that you are "mixing" Angular programming way with JS/JQuery way...
You should use features as "local Reference" and @ChildView to reference your modal, and avoid classic $("#detail") or document.getElementById('stock'). For instance, to referer to your 'detail' div: HTML:
<div #detail class="modal fade" id="detail">
TS:
import {Component, OnInit, ViewChild, ...} from '@angular/core';
@ViewChild('detail') detail: TemplateRef<any>;
detail_modal() {
// this.menu would be the reference to your div
const modal = this.open(this.menu , { windowClass: 'modal-md' });
modal.result.then(
(res) => {
// Button ok
},
(error) => {
// Button Cancel
});
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
