我有与日期有关的记录:
DATE AMOUNT
16.03.2013 3
16.03.2013 4
16.03.2013 1
16.03.2013 3
17.03.2013 4
17.03.2014 3
Run Code Online (Sandbox Code Playgroud)
我知道如何总结每一天,但我怎么能在一周之前总结一下呢?
我喜欢在Perl中编写OO代码,如下所示:
use MooseX::Declare;
use Method::Signatures::Modifiers;
use v5.14.2;
class Talker
{
method talk (Str $text) {
$self=>say $text;
}
my $talk_object = Talker->new();
$talk_object->talk('Hello!');
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,这很慢,我找不到任何鼠标或Moo相当于它.很遗憾Perl没有像PyPy那样的东西.
有人知道如何使用较轻的实现存档相同的内容吗?
我修改了以下PL/SQL BULK-COLLECT,它可以快速地在巨大的表(> 50.000.000)上进行更新.唯一的问题是,它不会执行每个表的剩余<5000行的更新.5000是FETCH指令的给定限制:
DECLARE
-- source table cursor (only columns to be updated)
CURSOR base_table_cur IS
select a.rowid, TARGET_COLUMN from TARGET_TABLE a
where TARGET_COLUMN is null;
TYPE base_type IS
TABLE OF base_table_cur%rowtype INDEX BY PLS_INTEGER;
base_tab base_type;
-- new data
CURSOR new_data_cur IS
select a.rowid,
coalesce(b.SOURCE_COLUMN, 'FILL_VALUE'||a.JOIN_COLUMN) TARGET_COLUMN from TARGET_TABLE a
left outer join SOURCE_TABLE b
on a.JOIN_COLUMN=b.JOIN_COLUMN
where a.TARGET_COLUMN is null;
TYPE new_data_type IS TABLE OF new_data_cur%rowtype INDEX BY PLS_INTEGER;
new_data_tab new_data_type;
TYPE row_id_type IS TABLE OF ROWID INDEX …Run Code Online (Sandbox Code Playgroud) 我有很多替换模式,我需要进行文本清理.我出于性能原因从数据库加载数据并编译正则表达式.不幸的是,在我的方法中,只有变量"text"的最后一个赋值似乎是有效的,而其他的似乎被覆盖了:
# -*- coding: utf-8 -*-
import cx_Oracle
import re
connection = cx_Oracle.connect("SCHEMA", "passWORD", "TNS")
cursor = connection.cursor()
cursor.execute("""select column_1, column_2
from table""")
# Variables for matching
REPLACE_1 = re.compile(r'(sample_pattern_1)')
REPLACE_2 = re.compile(r'(sample_pattern_2)')
# ..
REPLACE_99 = re.compile(r'(sample_pattern_99)')
REPLACE_100 = re.compile(r'(sample_pattern_100)')
def extract_from_db():
text = ''
for row in cursor:
# sidenote: each substitution text has the the name as the corresponding variable name, but as a string of course
text = REPLACE_1.sub(r'REPLACE_1',str(row[0]))
text = REPLACE_2.sub(r'REPLACE_2',str(row[0]))
# ..
text = …Run Code Online (Sandbox Code Playgroud) 我有一个文件名目录,其中缺少点,这标志着文件扩展名的开头:
filename1jpg
filename2JPG
filename3MPG
Run Code Online (Sandbox Code Playgroud)
我现在想.在行的末尾添加一个第三个位置,以便将文件名重命名为:
filename1.jpg
filename2.JPG
filename3.MPG
Run Code Online (Sandbox Code Playgroud)
最方便的可能是rename在shell上,但我无法想象一个正则表达式.有人能帮我吗?
对于 X 中的所有表,而 X 是
select table_name from all_tab_cols
where column_name = 'MY_COLUMN'
and owner='ADMIN'
Run Code Online (Sandbox Code Playgroud)
我需要检查列 MY_COLUMN 是否具有“Y”或“N”以外的其他值,如果有,则打印出表名称。
伪代码:
for table in X:
if MY_COLUMN !='Y' or MY_COLUMN !='N':
print table
Run Code Online (Sandbox Code Playgroud)
我想如何在 PL/SQL 中使用游标来实现它?
这可能很荒谬,但我无法理解在 Python 中使用全局变量。它给我抛出了使用关键字的语法错误
global
Run Code Online (Sandbox Code Playgroud)
尽管如此,我在文档中确实是这样查找的。
我知道代码由于重复使用全局变量而显得笨拙。无论如何,如何正确使用它们?
import random
r_list = []
my_list =[3,4,45,7,23,33]
match_list=[]
iteration = 0
number_matches = 0
def fill_random_list():
for i in range(7):
# print (random.randint(1,49))
r_list.append(random.randint(1,49))
def return_matches(lista, listb):
# print set(lista).intersection(listb)
return set(lista).intersection(listb)
def return_number_matches(l_matches):
if l_matches:
return len(l_matches)
def draw_lottery():
while global number_matches < 5:'''
File "C:/Lottery.py", line 27
while global number_matches < 5:
^
SyntaxError: invalid syntax'''
global r_list = []
global match_list = []
fill_random_list()
match_list=return_matches(r_list, my_list)
global number_matches=(return_number_matches(global match_list))
global iteration+=1 …Run Code Online (Sandbox Code Playgroud) oracle ×3
perl ×2
plsql ×2
python ×2
regex ×2
sql ×2
bash ×1
bulk-collect ×1
bulkupdate ×1
cursor ×1
linux ×1
moose ×1
oop ×1
performance ×1