我要解决的问题是,我想将sqlite3查询结果保存在变量中,我创建了以下代码:
import sqlite3
conn=sqlite3.connect('Database.db')
c=conn.cursor()
#this is implicit, but there is no xxx row in my table, condition and something
#arent real parameters for my query
qry=("SELECT xxx FROM xxx WHERE condition=something")
y=c.execute(qry)
print(y)
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,我得到以下内容:
<sqlite3.Cursor object at 0x01FCD6A0>
Run Code Online (Sandbox Code Playgroud)
现在,例如,如果我使用了for循环在该查询中打印行:
for row in c.execute(qry):
print(row)
Run Code Online (Sandbox Code Playgroud)
我没有问题,但是我想将查询打印的值保存在变量中,应该注意的是,我正在尝试保存具有单行单列的查询,例如: ('EXAMPLE',)
有没有一种方法可以将单行,单列查询保存在变量中,然后打印出来?我应该安装一些模块吗?
我正在 Webstorm 中开发一个具有以下文件结构的项目
| src
| ...
| many files
| types
| SomeInterface
| index.d.ts
| AnotherInterface
| index.d.ts
| index.d.ts
Run Code Online (Sandbox Code Playgroud)
我想使其SomeInterface在全球范围内可用(使用接口而不需要导入)。
我的主要内容index.d.ts如下:
import { SomeInterface } from './SomeInterface'
import { AnotherInterface} from './AnotherInterface'
declare global {
interface MainInterface extends SomeInterface {
someAttribute?: number[]
names: SomeInterface[]
contactData: AnotherInterface[]
}
}
Run Code Online (Sandbox Code Playgroud)
每当我尝试在以下位置实现类型定义时src/some/path/to/file.ts:
function someFunctionName(parsedData: MainInterface):void{...}
Run Code Online (Sandbox Code Playgroud)
我收到以下消息:
ESLint: 'MainInterface' is not defined.(no-undef)
这是我当前的 tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"allowJs": true,
"checkJs": true,
"module": "esnext", …Run Code Online (Sandbox Code Playgroud)