www.91084.com

GVKun编程网logo

Connect to MSSQL Database using Flask-SQLAlchemy

4

在这篇文章中,我们将为您详细介绍ConnecttoMSSQLDatabaseusingFlask-SQLAlchemy的内容。此外,我们还会涉及一些关于68.YouaremanaginganOracl

在这篇文章中,我们将为您详细介绍Connect to MSSQL Database using Flask-SQLAlchemy的内容。此外,我们还会涉及一些关于68.You are managing an Oracle Database 11g database. You want to ensure the recovery of the database、73.You are managing an Oracle Database 11g database. You configured the database to run in ARCHIVELO、78.You are managing an Oracle Database 11g database. The database is open, and you plan to perform R、dblogin userid ogg ERROR: Unable to connect to database using user ogg的知识,以帮助您更全面地了解这个主题。

本文目录一览:

Connect to MSSQL Database using Flask-SQLAlchemy

Connect to MSSQL Database using Flask-SQLAlchemy

我正在尝试通过SQLAlchemy连接到本地MSSQL数据库。
以下是我的\uu init\uuuuy文件的代码摘录:

from flask import Flaskfrom flask_sqlalchemy import SQLAlchemyapp = Flask(__name__)app.config[''SQLALCHEMY_DATABASE_URI''] = ''mssql+pyodbc://HARRISONS-THINK/LendApp''db = SQLAlchemy(app)SQLALCHEMY_TRACK_MODIFICATIONS = False

下面是在我的型号.py文件:

from LendApp import dbclass Transaction(db.model):    transactionID = db.Column(db.Integer, primary_key=True)    amount = db.Column(db.Integer)    sender = db.Column(db.String(80))    receiver = db.Column(db.String(80))    def __repr__(self):        return ''Transaction ID: {}''.format(self.transactionID)

然后我使用Pycharm中的Python控制台连接到数据库
这两条线的执行:

>>> from LendApp import db>>> db.create_all()

This is resulting in the following error:

DBAPIError: (pyodbc.Error) (''IM002'', ''[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)'')

我唯一能想到的就是我的数据库连接字符串不正确。我试着把它改成更标准的Pyodbc连接
字符串和includingdriver={sqlserver}但不占上风。如果有人能帮我解决这个问题,我将不胜感激。
谢谢

答案1

小编典典

所以我遇到了一个非常类似的问题,通过做
跟随。
遵循[SQL炼金术]
[文件](http://docs.sqlalchemy.org/en/latest/dialogs/mssql.html#模块-
sqlalchemy.dialones.mssql语言.pyodbc)我发现我可以使用我的pyodbc连接
字符串如下:

# Python 2.ximport urllibparams = urllib.quote_plus("DRIVER={SQL Server Native Client 10.0};SERVER=dagger;DATABASE=test;UID=user;PWD=password")engine = create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)# Python 3.ximport urllibparams = urllib.parse.quote_plus("DRIVER={SQL Server Native Client 10.0};SERVER=dagger;DATABASE=test;UID=user;PWD=password")engine = create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)# using the above logic I just did the followingparams = urllib.parse.quote_plus(''DRIVER={SQL Server};SERVER=HARRISONS-THINK;DATABASE=LendApp;Trusted_Connection=yes;'')app.config[''SQLALCHEMY_DATABASE_URI''] = "mssql+pyodbc:///?odbc_connect=%s" % params

This then caused an additional error because I was also using Flask-Migrate
and apparently it doesn’t like % in the connection URI. So I did some more
digging and found this post.
I then changed the following line in my ./migrations/env.py file

From:

from flask import current_appconfig.set_main_option(''sqlalchemy.url'',                   current_app.config.get(''SQLALCHEMY_DATABASE_URI''))

To:

from flask import current_appdb_url_escaped = current_app.config.get(''SQLALCHEMY_DATABASE_URI'').replace(''%'', ''%%'')config.set_main_option(''sqlalchemy.url'', db_url_escaped)

在做了所有这些之后,我能够进行迁移,一切看起来都像
它现在工作正常。

68.You are managing an Oracle Database 11g database. You want to ensure the recovery of the database

68.You are managing an Oracle Database 11g database. You want to ensure the recovery of the database

68.You are managing an Oracle Database 11g database. You want to ensure the recovery of the database to the point of failure. Which configuration will you do to accomplish the task? A.Multiplex all database files. B.Configure the Flash Recovery Area. C.Configure the database instance for ARCHIVELOG mode. D.Configure the FAST_START_MTTR_TARGET initialization parameter. 答案:C 解析:这个说是恢复到错误发生的时间点,这个相当于不完全恢复,不完全恢复的先觉条件是@R_301_6250@处于归档模式 当@R_301_6250@设置为归档模式之后对@R_301_6250@意味着 1.当@R_301_6250@(磁盘或系统文件问题所导致的)崩溃之后,所有提交的数据都能恢复 2.可以对@R_301_6250@进行联机备份,而且在联机备份期间可以继续进行其他的操作 3.当某一非系统表空间脱机时,@R_301_6250@的其他部分继续正常工作 4.可以进行如下的不完全恢复 a.恢复到某一特定的时间点 b.恢复到某一特定的scn号 c.恢复到某一特定的归档文件的结尾

73.You are managing an Oracle Database 11g database. You configured the database to run in ARCHIVELO

73.You are managing an Oracle Database 11g database. You configured the database to run in ARCHIVELO

73.You are managing an Oracle Database 11g database. You configured the database to run in ARCHIVELOG mode. Which two statements are true in this scenario? (Choose two.) A.You must shut down the database instance to perform the backups. B.You must configure the Flash Recovery Area (FRA) for the database. C.You can perform complete database backups without closing the database. D.All the prevIoUs closed database backups including control files become invalid after you configure the database to ARCHIVELOG mode. 答案:CD 解析: A.归档模式后,备份不需要关闭数据库,属于热备,因此A是错误的,当然也可以关闭进行一致性备份,但不是必须关闭数据库 B.fra默认路径为$ORACLE_BASE/fast_recovery_area,不需要费的配置,因此B也是错误的 C.正确,备份的时候,是备份了一个点,然后通过归档日志执行前滚实现了完全备份 D.正确,当打开归档后 sql> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 77 Next log sequence to archive 77 Current log sequence 79 这里的Current log sequence将会被重置为1,也就是之前的都变成了invalid

78.You are managing an Oracle Database 11g database. The database is open, and you plan to perform R

78.You are managing an Oracle Database 11g database. The database is open, and you plan to perform R

78.You are managing an Oracle Database 11g database. The database is open,and you plan to perform Recovery Manager (RMAN) backups. Which three statements are true about these backups? (Choose three.) A.The backups would be consistent. B.The backups would be inconsistent. C.The backups would be possible only if the database is running in ARCHIVELOG mode. D.The backups would be possible only if the database is running in NOARCHIVELOG mode. E.The backups need to be restored and the database has to be recovered in case of a media failure. 答案:BCE 解析:只要是open状态进行备份的都是不一致备份排除A rman在非归档模式下执行进行脱机备份也就是冷备,因此排除D E说的是介质有问题了,备份必须restore然后recovered,这里说一下restore和recover的区别 restore:从备份位置还原一个或者多个数据库文件 recover:应用归档和联机重做日志文件,将整个数据库或单独数据库文件前滚到指定的scn 这就是归档文件的作用,当执行备份的时候,只是备份到一个点的数据,但是在备份之后这段时间执行的数据,就需要 通过recover利用归档日志,来进行前滚实现,因此需要这两步

dblogin userid ogg ERROR: Unable to connect to database using user ogg

dblogin userid ogg ERROR: Unable to connect to database using user ogg

测试环境,初步配置ogg,添加ogg用户连接数据库,提示无权限报错。

 

1.0 报错信息

GGSCI (enmo) 1> dblogin userid ogg,password ogg 
ERROR: Unable to connect to database using user ogg. Please check privileges.
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory.

 

2.0 数据库用户登录,权限排查

SQL> create user test001 identified by test001;   

User created.

SQL> 
SQL> grant dba to test001;

Grant succeeded.

从报错字面理解报错信息: 无法连接数据库Ogg用户,请检查权限,数据库没有问题,Ogg是否存在问题

[ogg@enmo ogg]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Jan 27 22:04:48 2019

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> 
SQL> exit
[ogg@enmo ogg]$ env|grep SID
ORACLE_SID=t2  发现sid不同,home/base已排除

3.0 修改oracle_sid

[ogg@enmo ogg]$ vi ~/.bash_profile 
修改oracle_sid内容
[ogg@enmo ogg]$ source ~/.bash_profile 

[ogg@enmo ogg]$ echo $ORACLE_SID
a11204 
[ogg@enmo ogg]$ ./ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.

GGSCI (enmo) 1> dblogin userid ogg,password ogg 
Successfully logged into database.

 

我们今天的关于Connect to MSSQL Database using Flask-SQLAlchemy的分享已经告一段落,感谢您的关注,如果您想了解更多关于68.You are managing an Oracle Database 11g database. You want to ensure the recovery of the database、73.You are managing an Oracle Database 11g database. You configured the database to run in ARCHIVELO、78.You are managing an Oracle Database 11g database. The database is open, and you plan to perform R、dblogin userid ogg ERROR: Unable to connect to database using user ogg的相关信息,请在本站查询。

本文标签: