鍍金池/ 問(wèn)答/ 數(shù)據(jù)庫(kù)問(wèn)答
巫婆 回答

用正則 Python正則表達(dá)式

#!/usr/bin/python
# -*- coding: UTF-8 -*- 
import re
 
str = "aabbcc!!";
 
searchObj = re.search( r'[,.!?,。!?]{2,}', str);
 
if searchObj:
   print("searchObj.group() : ", searchObj.group());
else:
   print("Nothing found!!");
入她眼 回答

session_handler相關(guān)函數(shù)貼一下,默認(rèn)是存文件的,你存數(shù)據(jù)庫(kù)證明這里有修改

選擇 回答

先完成緊急的業(yè)務(wù)需求,之后在重新弄個(gè)int(38)的字段,因?yàn)楸旧磉@個(gè)就該弄成整數(shù)的,再去填充數(shù)值,而沒(méi)必要去弄個(gè)varchar ,或者你直接給varchar添加個(gè)索引

情皺 回答
網(wǎng)妓 回答

1樓已經(jīng)回答了

哚蕾咪 回答

性能可能會(huì)有影響,因?yàn)楸緛?lái)是需要直接執(zhí)行點(diǎn)擊事件對(duì)應(yīng)的方法就可以了,你現(xiàn)在是直接觸發(fā)點(diǎn)擊事件,然后間接的執(zhí)行對(duì)應(yīng)的方法。不過(guò)在我看來(lái)影響可能比較小。性能可能直觀上看不出來(lái)。最好的方法是調(diào)用事件對(duì)應(yīng)的方法。而你這個(gè)程序沒(méi)有,那就調(diào)用form的submit方法

$('form').submit()
陪我終 回答

類(lèi)的方法 可以同時(shí)被多個(gè)線程執(zhí)行,除非對(duì)方法加鎖。
類(lèi)加載時(shí) 方法信息保存在一塊稱(chēng)為方法區(qū)的內(nèi)存中,你可以把方法信息理解為 一段代碼信息,這個(gè)數(shù)據(jù)是不變的,多個(gè)線程都能讀取執(zhí)行。

背叛者 回答

你的MySQL是什么版本,自己編譯的嗎?
對(duì)這個(gè)參數(shù)有點(diǎn)印象,MySQL官方說(shuō)明中對(duì)其有介紹,默認(rèn)設(shè)置為NULL,據(jù)說(shuō)會(huì)禁止數(shù)據(jù)導(dǎo)入導(dǎo)出;也有設(shè)置成DINSTALL_SECURE_FILE_PRIVDIR=/usr/local/mysql/mysql-files這樣的非NULL,包括空值,不過(guò)空值會(huì)有問(wèn)題:

A non-NULL value is considered insecure if it is empty, or the value is the data directory or a subdirectory of it, or a directory that is accessible by all users. If secure_file_priv is set to a nonexistent path, the server writes an error message to the error log and exits.

大體這意思是說(shuō),最好指向一個(gè)真實(shí)存在的目錄,且系統(tǒng)用戶均可訪問(wèn)。我記得說(shuō)明手冊(cè)上寫(xiě)的范例是在/usr/local/mysql這個(gè)目錄下新建。

未命名 回答

fpm 配置max_requests 每個(gè)fpm 處理請(qǐng)求數(shù)超過(guò)這個(gè)數(shù)就會(huì)重啟。應(yīng)該是你們業(yè)務(wù)在那個(gè)時(shí)間段正好使得fpm請(qǐng)求數(shù)操作了閾值,造成fpm 進(jìn)程同時(shí)重啟,可以處理請(qǐng)求的fmp數(shù)目只有少數(shù),造成502??梢詤⒖?a rel="nofollow noreferrer">http://www.yunweipai.com/arch...

痞性 回答

是可以的,但是感覺(jué)name-time-list:date這個(gè)有些多余,可以考慮使用 data 就使用 集合,可以將時(shí)間戳放到第一位

淚染裳 回答

Column 對(duì)象 的 in_ 方法。
filter需要傳遞的參數(shù)為表達(dá)式,此處剛好。
filter_by需要傳遞關(guān)鍵字參數(shù),所以此處in_沒(méi)法使用。

in_OOP非OOP兩種模式中的使用-demo:

# 通用
from sqlalchemy import (
    create_engine,
    Column,
    Integer,
    String
)

# oop方式所需
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

# 非oop方式所需
from sqlalchemy import (
    Table,
    MetaData,
)
from sqlalchemy.sql import func


Base = declarative_base()

class Table1(Base):
    __tablename__ = 'table1'

    id = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String(55))

    def __init__(self, name):
        super(Table1, self).__init__()
        self.id = None
        self.name = name

    def __repr__(self):
        return '<Table1 {0}>'.format(self.id if not self.id is None else '')

uri = 'sqlite:///:memory:'
engine = create_engine(uri)
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine, autocommit=False)

############# 添加對(duì)象, 填充測(cè)試數(shù)據(jù)
session = Session()
for name in 'zhang,wang,li,gong,chen,zhao'.split(','):
    obj = Table1(name)
    session.add(obj)
session.commit()

lst_filter = ['wang', 'li', 'zhao']
############# OOP方式查詢
# 查詢總數(shù)
Q = session.query(Table1)
print(Q.count())
# 篩選
Q = Q.filter(Table1.name.in_(lst_filter))
result = Q.all()
print(result)
session.close()

############# 非OOP方式查詢
metadata = MetaData(bind=engine)
table = Table('table1', metadata, autoload=True)

# 查詢總數(shù)
stmt = func.count(table).select()
print(stmt.execute().fetchone())
# 篩選
stmt = table.select().where(table.c.name.in_(lst_filter))
rp = stmt.execute()
result = rp.fetchall()
# print(result)
print(len(result))

engine.dispose()

執(zhí)行結(jié)果:

6
[<Table1 2>, <Table1 3>, <Table1 6>]
(6,)
3

參考:

  • in_

    Implement the in operator.
    In a column context, produces the clause a IN other. “other” may be a tuple/list of column expressions, or a select() construct.
  • filter

    apply the given filtering criterion to a copy of this Query, using SQL expressions.
  • filter_by

    apply the given filtering criterion to a copy of this Query, using keyword expressions.
INSERT INTO members_setmeal(uid, setmealid)
SELECT t.uid, 1
FROM 
(SELECT m.uid
FROM members m
WHERE NOT EXISTS(SELECT 1 FROM members_setmeal ms WHERE ms.uid = m.uid)) t;
莫小染 回答

大眼一掃,目測(cè)你把參數(shù)拼寫(xiě)錯(cuò)誤了

毀憶 回答

可以先擴(kuò)展一下『第二個(gè)想法』,Product存tags字段,自然Tag也能存products字段存放這個(gè)標(biāo)簽有哪些product,你要?jiǎng)h某個(gè)tag,把這個(gè)tag的products拿出來(lái)遍歷一部分即可,也就是這份『關(guān)系』同時(shí)在Product和Tag冗余一份。但是這樣做要不了多久products字段非常大,實(shí)操下來(lái)肯定很慢。

那么結(jié)合『第一個(gè)想法』,不要products字段,只要tags字段,再加上做了索引的ProductTag中間表,平時(shí)不用ProductTag,一旦要?jiǎng)htag,從ProductTag表讀,然后一個(gè)個(gè)去處理Product的tags字段。

希望能幫助到你。

commit提交一下。或者改成使用with語(yǔ)句。
從不看教程不看文檔的嗎?

念舊 回答

解決nodejs require module時(shí)循環(huán)引用會(huì)導(dǎo)致undefined的問(wèn)題
這個(gè)一般在定義關(guān)聯(lián)的時(shí)候會(huì)用。
目前我的做法是把所有model的關(guān)聯(lián)放到一個(gè)js去做

import { Authorize, AuthorizeAttributes, AuthorizeInstance } from './authorize';
import { Comment, CommentAttributes, CommentInstance } from './comment';
import { Hit, HitAttributes, HitInstance } from './hit';
import { Moneylog, MoneylogAction, MoneylogAttributes, MoneylogInstance } from './moneylog';
import { Order, OrderAttributes, OrderInstance } from './order';
import { Post, PostAttributes, PostContentType, PostInstance } from './post';
import { Poundage, PoundageAttributes, PoundageInstance } from './poundage';
import { User, UserAttributes, UserInstance } from './user';
import { Withdrawal, WithdrawalAttributes, WithdrawalInstance } from './withdrawal';

Comment.belongsTo(Post, { foreignKey: 'post_id', as: 'post' });
Comment.belongsTo(User, { foreignKey: 'user_id', as: 'user' });

Order.belongsTo(User, { foreignKey: 'user_id', as: 'user' });
Order.belongsTo(Post, { foreignKey: 'post_id', as: 'post' });

Post.belongsTo(User, { foreignKey: 'user_id', as: 'user' });
Post.hasMany(Comment, { foreignKey: 'post_id', as: 'commentList' });

User.hasMany(Post, { foreignKey: 'user_id', as: 'posts' });
User.hasMany(Order, { foreignKey: 'user_id', as: 'orders' });
User.hasMany(Comment, { foreignKey: 'user_id', as: 'comment' });
夏木 回答

root 設(shè)置密碼了么?

神曲 回答

clipboard.png

不重復(fù)的選擇的話可以用distinct

select distinct(民族) from `學(xué)生`;