date

sqlalchemy 多对多关系

本小妞迷上赌 提交于 2020-03-17 04:45:27
一、前言   多对多的关系是一张表可以关联多张表。    现在来设计一个能描述“图书”与“作者”的关系的表结构,需求是 一本书可以有好几个作者一起出版 一个作者可以写好几本书 二、表结构和数据    book_m2m_author表由author表和book表生成 三、事例 from sqlalchemy import Table, Column, Integer, String, DATE, ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import create_engine # 如果插入数据有中文,需要指定 charset=utf8 engine = create_engine("mysql+pymysql://bigberg:111111@172.16.200.49:3306/study?charset=utf8", encoding='utf-8') Base = declarative_base() # 创建orm基类 Base.metadata.create_all(engine) # 这个表的创建后,不需要维护 book_m2m_author = Table("book

Python: third Friday of a month

若如初见. 提交于 2020-03-17 04:37:01
问题 I am a rookie python programmer and I need to write a script to check if a given date (passed as a string in the form 'Month, day year') is the third Friday of the month. I am using Python 2.7. For example, these dates can help you better understand my problem. Have a yearly calendar at hand. input ---> output 'Jan 18, 2013' ---> True 'Feb 22, 2013' ---> False 'Jun 21, 2013' ---> True 'Sep 20, 2013' ---> True I just want to use standard classes provided by the language, like time, datetime,

NumberFormatException while parsing date with SimpleDateFormat.parse()

与世无争的帅哥 提交于 2020-03-17 04:19:09
问题 Have a function that creates a time-only Date object. (why this is required is a long story which is irrelevant in this context but I need to compare to some stuff in XML world where TIME (i.e. time-only) is a valid concept). private static final SimpleDateFormat DF_TIMEONLY = new SimpleDateFormat("HH:mm:ss.SSSZ"); public static Date getCurrentTimeOnly() { String onlyTimeStr = DF_TIMEONLY.format(new Date()); // line #5 Date onlyTimeDt = null; try { onlyTimeDt = DF_TIMEONLY.parse(onlyTimeStr);

Get the time and date of git tags

馋奶兔 提交于 2020-03-17 04:00:05
问题 I have a project that is using git and have tagged all the releases with a tag. $ git tag v1.0.0 v1.0.1 v1.0.2 v1.0.3 v1.1.0 My goal is to list the releases and release dates in a web interface (tag/commit date = release date). Currently we list all the releases by using git tag . How can I get the time and date for when the tag was made (or the commit it points to)? 回答1: Use the --format argument to git log : git log -1 --format=%ai MY_TAG_NAME 回答2: This always worked for me: git log --tags

mysql自动备份

雨燕双飞 提交于 2020-03-17 01:36:00
echo -e '******Start********'$(date '+%Y%m%d%H%M%S')>>/storage/test/srdb_bak/blog.txt #日志打印 rq='srdb'$(date '+%Y%m%d')'01' #动态编写时间 orq='srdb'$(date -d'2 day ago' +'%Y%m%d')'01' #当前时间减去2天 echo -e $rq $orq>>/storage/test/srdb_bak/blog.txt nohup mkdir -p /storage/test/srdb_bak/$rq & mydumper -h 177.17.10.100 -P 33036 -u smart -p smartmin -t 32 -F 5 -B srdb --no-schemas --no-views --skip-tz-utc -o /storage/test/srdb_bak/$rq >> dump_$rq.log & #导出数据库文件 find /storage/test/srdb_bak -name $orq |xargs rm -rf #压删除最近2天之外的数据 echo -e '******End**********'$(date '+%Y%m%d%H%M%S')>>/storage/test/srdb_bak/blog

日志解析+调用Web Service服务保存至数据库,再调用服务查询数据

拜拜、爱过 提交于 2020-03-17 01:16:04
某厂面试归来,发现自己落伍了!>>> using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.IO; using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { ServiceReference1.WebService1SoapClient ws = new ServiceReference1.WebService1SoapClient(); string sWhere = ""; if (textBox1.Text != "") { sWhere +=" AND [USER] = '" +textBox1

教你用纯 Java 实现一个网页版的 Xshell(附源码)

喜欢而已 提交于 2020-03-17 01:14:52
本人免费整理了Java高级资料,涵盖了Java、Redis、MongoDB、MySQL、Zookeeper、Spring Cloud、Dubbo高并发分布式等教程,一共30G,需要自己领取。 传送门: https://mp.weixin.qq.com/s/osB-BOl6W-ZLTSttTkqMPQ 前言 最近由于项目需求,项目中需要实现一个WebSSH连接终端的功能,由于自己第一次做这类型功能,所以首先上了GitHub找了找有没有现成的轮子可以拿来直接用,当时看到了很多这方面的项目,例如:GateOne、webssh、shellinabox等,这些项目都可以很好地实现webssh的功能。 但是最终并没有采用,原因是在于这些底层大都是python写的,需要依赖很多文件,自己用的时候可以使用这种方案,快捷省事,但是做到项目中供用户使用时,总不能要求用户做到服务器中必须包含这些底层依赖,这显然不太合理,所以我决定自己动手写一个WebSSH的功能,并且作为一个独立的项目开源出来。 github项目开源地址:https://github.com/NoCortY/WebSSH 技术选型 由于webssh需要实时数据交互,所以会选用长连接的WebSocket,为了开发的方便,框架选用SpringBoot,另外还自己了解了Java用户连接ssh的jsch和实现前端shell页面的xterm.js

教你用纯 Java 实现一个网页版的 Xshell(附源码)

杀马特。学长 韩版系。学妹 提交于 2020-03-17 00:29:34
某厂面试归来,发现自己落伍了!>>> 【推荐】2020年最新Java电子书集合.pdf(吐血整理) >>> 前言 最近由于项目需求,项目中需要实现一个WebSSH连接终端的功能,由于自己第一次做这类型功能,所以首先上了GitHub找了找有没有现成的轮子可以拿来直接用,当时看到了很多这方面的项目,例如:GateOne、webssh、shellinabox等,这些项目都可以很好地实现webssh的功能。 但是最终并没有采用,原因是在于这些底层大都是python写的,需要依赖很多文件,自己用的时候可以使用这种方案,快捷省事,但是做到项目中供用户使用时,总不能要求用户做到服务器中必须包含这些底层依赖,这显然不太合理,所以我决定自己动手写一个WebSSH的功能,并且作为一个独立的项目开源出来。 github项目开源地址:https://github.com/NoCortY/WebSSH 技术选型 由于webssh需要实时数据交互,所以会选用长连接的WebSocket,为了开发的方便,框架选用SpringBoot,另外还自己了解了Java用户连接ssh的jsch和实现前端shell页面的xterm.js. 所以, 最终的技术选型就是 SpringBoot+Websocket+jsch+xterm.js 。 导入依赖 < parent > < groupId > org

Hibernate的联合主键注解方式

a 夏天 提交于 2020-03-16 11:57:55
某厂面试归来,发现自己落伍了!>>> Hibernate联合主键注解方式,即是Hibernate中某一张表出现多个字段联合为唯一主键的情况。这时候就可以使用Hibernate的联合主键来操作。以用户表为例子,userId+userName为唯一主键,因为有时候会出现多个用户的姓名是一样的,如果加上userId就可以控制唯一,判断是否是同一个用户。 注: 主键类 (UserPK类)是指只有userId和userName的联合字段的类,即是多个字段联合为主键的类==联合主键类。 实体类 是指用户表的User类。 方式一 主键类(UserPK类): 该类实现 java.io.Serializable 接口,并重写 equals 和 hascode,再将 该类注解为 @Embeddable。 实体类(User类):该类不包含主键类中的字段,但是需要保存联合主键类的引用,并且生成set和get方法, 并将该引用注解为 @Id 。实体类注解为@Entity和@Table。 实体类: import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import java.io.Serializable;

当前凌晨时间戳

给你一囗甜甜゛ 提交于 2020-03-16 11:09:07
echo strtotime(date('Y-m-d')); 获取明天凌晨的时间戳 代码:echo strtotime(date('Y-m-d',strtotime('+1 day'))); 附上测试代码: echo strtotime('2012-11-2'); echo strtotime('2012-11-2 00:00:00'); echo strtotime(date('Y-m-d')),' '; echo date('Y-m-d H:i:s',strtotime(date('Y-m-d'))); echo strtotime(date('Y-m-d',strtotime('+1 day'))); echo ( strtotime(date('Y-m-d',strtotime('+1 day'))) - strtotime(date('Y-m-d')) )/3600; 其它参考代码: echo "一周后:".date("Y-m-d",strtotime("+1 week")); echo "一周零两天四小时两秒后:".date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds")); echo "下个星期四:".date("Y-m-d",strtotime("next Thursday")); echo