我正在使用SQLAlchemy来配置我的数据库模式,我想根据数据库方言设置一个private PageFragment pageOne;
private PageFragment pageTwo;
private PageFragment pageThree;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View layout = inflater.inflate(R.layout.fragment_stats, container, false);
TabLayout tabLayout = (TabLayout)layout.findViewById(R.id.tab_layout);
pageOne = PageFragment.newInstance(0);
pageTwo = PageFragment.newInstance(1);
pageThree = PageFragment.newInstance(2);
tabLayout.addTab(tabLayout.newTab().setText("7 days"));
tabLayout.addTab(tabLayout.newTab().setText("1 month"));
tabLayout.addTab(tabLayout.newTab().setText("1 year"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final CustomViewPager viewPager = (CustomViewPager) layout.findViewById(R.id.pager);
final ViewPagerAdapter adapter = new ViewPagerAdapter(getActivity().getSupportFragmentManager());
adapter.addFragment(pageOne,"7 days");
adapter.addFragment(pageTwo,"1 month");
adapter.addFragment(pageThree,"1 year");
viewPager.setAdapter(adapter);
viewPager.setPagingEnabled(false);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
return layout;
}
,其中Column
是不同的。一个数据库函数调用PostgreSQL,另一个调用SQLite。可以这样做吗?怎么样?
server_default
答案 0 :(得分:2)
使用from sqlalchemy import Column, DateTime
class CustomNow():
pass # What to do?
class Timestamps(object):
created = Column(DateTime, server_default=CustomNow())
decorartor,如the docs:
@compiles