我正在尝试将.csv文件中的数据插入到sqlalchemy表中-除字符串外的所有数据类型均已正确插入表中。
csv数据的示例是:
Version=1.1
636706156850400000,-1.54752188,53.79451,HUL4,3809,20,1014.63495,M
636706156850800000,-1.54752056,53.7945102,HUL4,3809,20,1014.53614,M
636706156851200000,-1.54751925,53.7945104,HUL4,3809,20,1014.43734,M
相关的python代码是:
class Gpxmm_Coverage(Base):
__tablename__ = 'Gpxmm_Coverage'
__table_args__ = {'sqlite_autoincrement': True}
id = Column(Integer, primary_key=True, nullable=False)
gps = Column(Integer)
x = Column(Float)
y = Column(Float)
elr = Column(String)
trid = Column(Integer)
m = Column(Integer)
yards = Column(Float)
type = Column(String)
但是,当浏览数据时(在Mac上使用DB浏览器用于SQLite),elr和type列显示为'NULL'。所有其他列均具有正确的值类型。
答案 0 :(得分:0)
elr
和type
时,请确保str
是length
。String
类型指定FirebaseRecyclerAdapter<NoteModel, NoteViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<NoteModel, NoteViewHolder>(
NoteModel.class,
R.layout.note_card,
NoteViewHolder.class,
fNotesDatabase) {
@Override
protected void populateViewHolder(final NoteViewHolder viewHolder, NoteModel model, int position) {
final String noteId = getRef(position).getKey();
Log.e("MainActivity","Populate View");
fNotesDatabase.child(noteId).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.hasChild("mTitle") && dataSnapshot.hasChild("mTime")) {
String title = dataSnapshot.child("mTitle").getValue().toString();
String timestamp = dataSnapshot.child("mTime").getValue().toString();
String content = dataSnapshot.child("mContent").getValue().toString();
GetTimeAgo getTimeAgo = new GetTimeAgo();
viewHolder.setTime(getTimeAgo.getTimeAgo(Long.parseLong(timestamp), getApplicationContext()));
viewHolder.setTitle(title);
//viewHolder.setNoteTime(timestamp);
viewHolder.setContent(content);
viewHolder.setTime(timestamp);
Log.e("MainActivity","Data retrieval"+title);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
};
recyclerView.setAdapter(firebaseRecyclerAdapter);
参数,例如列(String(64))https://docs.sqlalchemy.org/en/latest/core/type_basics.html#sqlalchemy.types.String